Skip to content

Unexpected partial hot code replacement in nondebug mode #4456

@xerces8

Description

@xerces8

Hi!

This may be a misunderstanding on my side, but here it is.

When running a Java program from Eclipse (I originally encountered this while running JUnit test cases in an older version of Eclipse, but plain Java programs in latest Eclipse behave the same) and the editing and saving the source code, the new version of the code will be used in some parts of the running app.

Steps:

  • version used: eclipse-jee-2025-09-R-win32-x86_64.zip
    About menu shows:

Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)

Version: 2025-09 (4.37.0)
Build id: 20250905-1456

  • open new workspace
  • create a new "Java Project"
  • create a new class, enter code source below
  • run it with "Run As / Java Application" (Alt+Shift+X,J)
  • while running change the value of the theValue variable to 999 and save (Ctrl+S)

Expected output:

first: 340
THREAD theValue = 340
second: 340

Actual output:

first: 340
THREAD theValue = 999
second: 340

package dummy;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Dummy {
	final static int theValue = 340;
	private final ExecutorService pool = Executors.newFixedThreadPool(2);

	void doIt() throws InterruptedException, ExecutionException {
		int first = theValue;
		System.out.println("first: " + first);

		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

		Future<Object> task = pool.submit(new Callable<Object>() {
			public Object call() {
				System.out.println(" THREAD  theValue = " + theValue);
				return null;
			}
		});

		task.get();

		int second = theValue;
		System.out.println("second: " + second);

	}

	public static void main(String[] args) throws InterruptedException, ExecutionException {
		new Dummy().doIt();
	}
}

Changing the preference Java / Debug "Enable hot code replace" to disabled makes no change to the above behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions