Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6547500
Votes 0
Synopsis j.l.i.: .retransformClasses throws unexpected InternalError
Category java:serviceability
Reported Against b105
Release Fixed 7(b26)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs
Submit Date 18-APR-2007
Description
Filed By       : JCK team
JDK            : java full version "1.6.0-fcs"
JCK            : 6a
Platform[s]    : FAIL - seems to be all
switch/Mode    : default
JCK test owner : http://javaweb.sfbay/jcce/tcks/jck/docs/others/owners.jto
Failed tests:
  api/java_lang/instrument/Instrumentation/index.html#Instrumentation[Instrumentation219]
  api/java_lang/instrument/Instrumentation/attach.html#InstrumentationAttach[Instrumentation219]

Problem description
===================
The javadoc specification for the Instrumentation.retransformClasses(Class<?>... classes) method at:
  http://javaweb.sfbay/java/re/jdk/6.0/latest/docs/api/java/lang/instrument/Instrumentation.html#retransformClasses(java.lang.Class...)
states as follows:
  ---Excerpt-from-spec---
  Throws:
  NullPointerException - if the supplied classes array or any of its components is null.
  ---End-of-excerpt---

However, the call of retransformClasses(Class<?>... classes) throws unexpected InternalError
if any of supplied classes array components is null.

Please see attached minimized test (test.tar.gz) to reproduce the failure.

Minimized test output:
======================
<  xxxxx@xxxxx  -espb04-125-170> java -javaagent:agent.jar Test
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
        at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:338)
Caused by: java.lang.InternalError: class redefinition failed: invalid class
        at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)        at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:124)
        at com.test.agent.Agent.doTest(Agent.java:23)
        at com.test.agent.Agent.premain(Agent.java:13)
        ... 6 more
FATAL ERROR in native method: processing of -javaagent failed

Additional info:
================
> uname -a
SunOS d-espb04-125-170 5.10 Generic_118833-33 sun4u sparc  xxxxx W,Ultra-60
Posted Date : 2007-04-18 18:23:28.0
Work Around
N/A
Evaluation
Instrumentation.retransformClasses() eventually gets down to
src/share/instrument/JPLISAgent.c:

void
retransformClasses(JNIEnv * jnienv, JPLISAgent * agent, jobjectArray classes) {

<snip>

    /* This was supposed to be checked by caller too */
    if (!errorOccurred && classes == NULL) {
        jplis_assert(classes != NULL);
        errorOccurred = JNI_TRUE;
        errorCode = JVMTI_ERROR_NULL_POINTER;
    }

// the above check catches a NULL classes array, but not an
// empty classes array which is what we are passed

    if (!errorOccurred) {
        numClasses = (*jnienv)->GetArrayLength(jnienv, classes);
        errorOccurred = checkForThrowable(jnienv);
        jplis_assert(!errorOccurred);

// we should check for numClasses == 0 here and set the
// right error conditions if it is 0
    }

    if (!errorOccurred) {
        classArray = (jclass *) allocate(retransformerEnv,
                                         numClasses * sizeof(jclass));
        errorOccurred = (classArray == NULL);
        jplis_assert(!errorOccurred);
        if (errorOccurred) {
            errorCode = JVMTI_ERROR_OUT_OF_MEMORY;
        }
    }

    if (!errorOccurred) {
        jint index;
        for (index = 0; index < numClasses; index++) {
            classArray[index] = (*jnienv)->GetObjectArrayElement(jnienv, classes, index);
            errorOccurred = checkForThrowable(jnienv);
            jplis_assert(!errorOccurred);

// we should check for a NULL array element here
// and set the right error conditions if it is NULL
Posted Date : 2008-01-31 22:36:32.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang