Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 337305 - Hot code replacing an inner class crashes the JVM
Summary: Hot code replacing an inner class crashes the JVM
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-16 08:05 EST by j.hertsig CLA
Modified: 2013-12-06 10:40 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description j.hertsig CLA 2011-02-16 08:05:45 EST
Build Identifier: M20100909-0800

Adding or removing a String constant in a class that will be hot code replaced, causes the JVM to crash if getEnclosingClass() is called on that object's class.

Reproducible: Always

Steps to Reproduce:
1. Create this class:
public class Test {
	private static final Object CONSTANT = new Object() {
		void unused() {
			System.out.println("123");
		}
	};
	
	public static void main(String[] args) {
		while(true) {
			System.out.println(CONSTANT.getClass().getEnclosingClass());
		}
	}
}
2. Run it in debug mode
3. (while it's running) add a statement that uses another String constant in the unused() method. A print works, but new String("234") works as well.
4. Save your modification. The class will be hot code replaced
5. The JVM crashes as soon as the getEnclosingClass() method is called on the replaced class.

I have filed this bug with Oracle as well, since the JVM should not crash. However, it might be possible to work around the JVM bug in Eclipse.
Comment 1 Michael Rennie CLA 2013-12-06 10:40:41 EST
Using the latest 1.6 / 1.7 VMs this works as expected.

Marking not_eclipse as it was likely a VM bug.