review request for JDK-8010428: Special -agentpath checks needed with minimal VM to produce proper error message

BILL PITTORE bill.pittore at oracle.com
Fri Apr 12 07:36:01 PDT 2013


Hi Carlos,
  Don't want to complicate this unnecessarily, but what if we had a list 
of valid agent names:

char *agent_names[] = {JNI_LIB_PREFIX "jdwp" JNI_LIB_SUFFIX, 
JNI_LIB_PREFIX "hprof" JNI_LIB_SUFFIX};

int num_names = sizeof(agent_names)/sizeof(char*);

for (i = 0; i < num_names; i++) {
     if (strcmp(agent_names[i], name) == 0) {
        return true;
     }
}

Then we could easily add new names to the list if necessary.
Even if you don't go this route, you can simplify your code somewhat by 
creating the agent names as shown above by prepending/appending the 
JNI_LIB string constants. Then you don't need to do the extra processing 
of the prefix/suffix; just one strcmp().

bill


On 4/12/2013 12:42 AM, Carlos Lucasius wrote:
> Please review the following fix for JDK-8010428 (Special -agentpath 
> checks needed with minimal VM to produce proper error message):
>
>     http://cr.openjdk.java.net/~clucasius/8010428/webrev00/
>
>
>
> Description (copied from 
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8010428):
>
>     If you try to use -agentpath to load libhprof.so or libjdwp.so
>     with the minimal VM, it fails with an unfriendly message that
>     doesn't indicate the real problem (hprof and jdwp not supported
>     with the minimal VM). For example:
>
>     $ bin/java -minimal
>     -agentpath:/export/home/aurora/jp/ejdk1.8.0/jre/lib/i386/libhprof.so
>     HPROF ERROR: Unable to access JVMTI Version 1 (0x30010000), is
>     your JDK a 5.0 or newer version? JNIEnv's GetEnv() returned -2
>     [hprof_util.c:1706]
>
>     The VM needs an explicit check for attempts to load libhprof.so or
>     libjdwp.so with -agentpath, and fail immediately with the proper
>     error message.
>
>
> Thanks,
>
> -Carlos
>
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/attachments/20130412/152c1e68/attachment.html 


More information about the hotspot-runtime-dev mailing list