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: 6328000
Votes 1
Synopsis class redefinition failed "method deleted"
Category hotspot:jvmti
Reported Against
Release Fixed mustang(b63), 5.0u8(b01) (Bug ID:2133509)
State 10-Fix Delivered, bug
Priority: 2-High
Related Bugs 6355014 , 6393258
Submit Date 23-SEP-2005
Description
FULL PRODUCT VERSION :
java version "1.6.0-ea"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-ea-b52)
Java HotSpot(TM) Client VM (build 1.6.0-ea-b52, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows 2000 [Version 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
For some classes, a call to retransformClasses fails with the following error, even when no transformers are present.

java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the class referenced below and package it as a java.lang.instrument Java agent with the provided manifest.  Run the Java2D demo shipped with the 1.6.0_b52 jdk, using this java Agent:

java -javaagent:TestAgent.jar -jar Java2Demo.jar


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
No UnsupportedOperationException errors during the retransformClasses calls since no transformers are present.

ACTUAL -
Two java.lang.UnsupportedOperationException errors occurred, even though no transformers were present.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
Retransform failed for class java2d.demos.Paint.TextureAnim$AnimVal
java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
        at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:116)
        at TestAgent.reloadClasses(TestAgent.java:47)
        at TestAgent.run(TestAgent.java:31)
        at java.lang.Thread.run(Thread.java:611)
Retransform failed for class java2d.Tools
java.lang.UnsupportedOperationException: class redefinition failed: attempted to delete a method
        at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
        at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:116)
        at TestAgent.reloadClasses(TestAgent.java:47)
        at TestAgent.run(TestAgent.java:31)
        at java.lang.Thread.run(Thread.java:611)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
TestAgent.java
------------------------------------------------------------------------------
import java.lang.instrument.*;

public class TestAgent
	implements Runnable
{
	private final Instrumentation fInstrumentation;

	public static void
	premain(	String agentArgs,
				Instrumentation instrumentation)
	{
		System.out.println("TestAgent started");
		new Thread(new TestAgent(instrumentation)).start();
	}
	
	public
	TestAgent(	Instrumentation instrumentation)
	{
		fInstrumentation = instrumentation;
	}

	public void
	run()
	{
		// wait for some classes to be loaded
		try { Thread.sleep(5000); } catch (InterruptedException ie) {}
		reloadClasses();
	}

    public void
    reloadClasses()
    {
        Class[] allClasses = fInstrumentation.getAllLoadedClasses();
        for (int i = 0; i < allClasses.length; i++)
        {
            try
            {
                // ignore arrays, primitives and classes loaded from the bootstrap loader
                if (!allClasses[i].isArray() &&
                    !allClasses[i].isPrimitive() &&
                     allClasses[i].getClassLoader() != null)
                {
                	fInstrumentation.retransformClasses(new Class[] { allClasses[i] });
                }
            }
            catch (Exception e)
            {
            	System.out.println("Retransform failed for " + allClasses[i]);
                e.printStackTrace();
            }
        }
    }
}
------------------------------------------------------------------------------


TestAgent.mf
------------------------------------------------------------------------------
Manifest-Version: 1.0
Premain-Class: TestAgent
------------------------------------------------------------------------------

---------- END SOURCE ----------
Posted Date : 2005-09-23 08:46:54.0

Response from filer:
Adding the Can-Retransform-Classes manifest entry appears to make the
problem go away for static agents (loaded using the -javaagent option).
The error message is still very misleading though.  Something like
"retransform not enabled for this agent" would make more sense.

The problem still occurs when loading the Agent via the remote attach
feature, even with this new manifest attribute.  I've attached an
updated TestAgent.jar with the new manifest attribute that also supports
remote attach.
It works using -javaagent but has the same problem when loaded via
remote attach.
Posted Date : 2005-09-23 22:36:33.0

--

I ran the test on Windows with b52 and it duplicates with -javaagent (not just a late-binding agent).
Posted Date : 2005-09-24 19:27:58.0
Work Around
N/A
Evaluation
The error stems from the an UNSUPPORTED_REDEFINITION_METHOD_DELETED from JVMTI's RedefineClasses so moving to hotspot/jvmti category.
Posted Date : 2005-09-23 13:06:31.0

jvmtiRedefineClasses.cpp assumes that methods, since they are sorted, are always in the same order.  However, they are sorted only on method name and thus overloaded methods may not have a consistent order.  This has been observed as a problem in class retransformation.
Posted Date : 2005-09-27 20:25:47.0

The assumption about method order remaining the same is true in
other parts of the VM also. Consider a class hierarchy where C1
is subclassed by C2 which is subclassed by C3. If C2 is redefined
and the order of overloaded methods are changed, then C3 (which
has not been redefined) can get confused about where to find its
super's version of a method.
Posted Date : 2005-11-21 17:22:43.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang