Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 565653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:53:41+00:00 2026-05-13T12:53:41+00:00

In order to use the instrumentation features introduced in JDK 5, you can use

  • 0

In order to use the instrumentation features introduced in JDK 5, you can use the -javaagent flag passed to the JVM. This will inject an instance of an Instrumentation class into the static premain method. For example in a class like this:

public class MyClass {
    public static Instrumentation inst;
    public static void premain(String options, Instrumentation inst) {
        MyClass.inst = inst;
    }
}

With an appropriate manifest file, you can run this as follows:

 java -javaagent:myfiles.jar SomeClass

This calls the premain method then main from SomeClass. This approach is used in the Java.SizeOf Project to guess at the approximate size of a Java object.

OK, now in Eclipse RCP each bundle has its own classloader. This means that the static Instrumentation that we stored in our MyClass is not visible to an Eclipse application. The javaagent uses one class-loader, the Eclipse bundles get loaded with another. When we access MyClass.inst from within a plugin it is null, as that class is not the same class as the one the javaagent loaded and called premain on.

Other clues as to a possible solution are this thread on the rcp mailing list. But nothing conclusive.

Is there any way to work around this? The Eclipse-BuddyPolicy hinted at in the eclipsezone article sounds good. I tried:

Eclipse-BuddyPolicy: app

in my plugins without luck. I need something like Eclipse-BuddyPolicy: javaagent. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T12:53:41+00:00Added an answer on May 13, 2026 at 12:53 pm

    I think the simplest solution is to use the global properties object. Have pre-main store the instrumentation object as a global properties and then access it from everywhere (the properties object is the same in all class loaders):

    [Edit: updated]

    public class MyClass {
        private static final String KEY = "my.instrumentation";
        public static void premain(String options, Instrumentation inst) {
            Properties props = System.getProperties();
            if(props.get(KEY) == null)
               props.put(KEY, inst);
        }
    
        public static Instrumentation getInstrumentation() { 
           return System.getProperties().get(KEY);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't think that I can use ORDER BY clause inside the GROUP_CONCAT function.
Please advice on where can I find the lib in order to use the
Is there any tutorial or resource I can follow in order to use the
In order to use Java FX in Netbeans I installed java jdk 7 by
OCaml process can use just one core and in order to use multiple cores
I need Oleaut32.lib in order to use SysAllocString C++ function but I can't find
Can we use Order By clause when we are using Select Query in Select
How can I use ORDER BY descending in a SQLAlchemy query like the following?
In order to use newid() in a UDF, I've created a view that can
can we use order by clause in view in sql server 2005? CREATE VIEW

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.