Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into BETA_JAVA23
Browse files Browse the repository at this point in the history
  • Loading branch information
jarthana committed Aug 5, 2024
2 parents fdfd6bb + 50f9bde commit 375b57a
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="/JarProject/lib/sample.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#Wed Aug 03 13:31:56 CDT 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.compiler.source=1.8
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected void setUp() throws Exception {
IFile jar = jarProject.getFile("lib/sample.jar");
assertTrue("lib/sample.jar is missing in project: " + jarProject.getName(), jar.exists());

fgJarProject = createJavaProjectClone(RefPjName, testrpath.append(RefPjName).toString(), JavaProjectHelper.JAVA_SE_1_7_EE_NAME, true);
fgJarProject = createJavaProjectClone(RefPjName, testrpath.append(RefPjName).toString(), JavaProjectHelper.JAVA_SE_1_8_EE_NAME, true);

IProject jarRefProject = fgJarProject.getProject();
IFile cp = jarRefProject.getFile(".classpath");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
* @noinstantiate This class is not intended to be instantiated by clients.
* @noextend This class is not intended to be subclassed by clients.
*/
@SuppressWarnings("deprecation")
public class JDIDebugModel {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected JDIStackFrame bind(StackFrame frame, int depth) {
// invalidate this frame
bind(null, -1);
// return a new frame
return new JDIStackFrame(fThread, frame, depth);
return fThread.newJDIStackFrame(frame, depth);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,7 @@ protected synchronized List<IJavaStackFrame> computeStackFrames(boolean refreshC
// create, if any
int depth = oldSize;
for (int i = newFrames - 1; i >= 0; i--) {
fStackFrames.add(0, new JDIStackFrame(this,
frames.get(i), depth));
fStackFrames.add(0, newJDIStackFrame(frames.get(i), depth));
depth++;
}
int numToRebind = Math.min(newSize, oldSize); // number of
Expand Down Expand Up @@ -665,6 +664,19 @@ protected synchronized List<IJavaStackFrame> computeStackFrames(boolean refreshC
return fStackFrames;
}

/**
* Creates new {@link JDIStackFrame} linked to current thread
*
* @param frame
* non null, underlying frame
* @param depth
* on the stack (0 is bottom)
* @return never null
*/
protected JDIStackFrame newJDIStackFrame(StackFrame frame, int depth) {
return new JDIStackFrame(this, frame, depth);
}

/**
* Returns this thread's current stack frames as a list, computing them if
* required. Returns an empty collection if this thread is not currently
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ISaveContext;
import org.eclipse.core.resources.ISaveParticipant;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -86,7 +87,9 @@
import org.eclipse.osgi.service.debug.DebugTrace;
import org.eclipse.osgi.util.NLS;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.prefs.BackingStoreException;
import org.osgi.util.tracker.ServiceTracker;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -192,6 +195,11 @@ public class LaunchingPlugin extends Plugin implements DebugOptionsListener, IEc
*/
private static DocumentBuilder fgXMLParser = null;

/**
* Service tracker for the workspace service
*/
private ServiceTracker<IWorkspace, IWorkspace> fWorkspaceServiceTracker = null;

/**
* Stores VM changes resulting from a JRE preference change.
*/
Expand Down Expand Up @@ -544,7 +552,7 @@ public void stop(BundleContext context) throws Exception {
JavaRuntime.removeVMInstallChangedListener(this);
JavaRuntime.saveVMConfiguration();
fgXMLParser = null;
ResourcesPlugin.getWorkspace().removeSaveParticipant(ID_PLUGIN);
fWorkspaceServiceTracker.close();
} finally {
super.stop(context);
}
Expand All @@ -559,24 +567,50 @@ public void start(BundleContext context) throws Exception {
Hashtable<String, String> props = new Hashtable<>(2);
props.put(org.eclipse.osgi.service.debug.DebugOptions.LISTENER_SYMBOLICNAME, getUniqueIdentifier());
context.registerService(DebugOptionsListener.class.getName(), this, props);
ResourcesPlugin.getWorkspace().addSaveParticipant(ID_PLUGIN, new ISaveParticipant() {
@Override
public void doneSaving(ISaveContext context1) {}
@Override
public void prepareToSave(ISaveContext context1) throws CoreException {}
@Override
public void rollback(ISaveContext context1) {}
fWorkspaceServiceTracker = new ServiceTracker<>(context, IWorkspace.class, null) {

@Override
public void saving(ISaveContext context1) throws CoreException {
public IWorkspace addingService(ServiceReference<IWorkspace> reference) {
IWorkspace workspace = context.getService(reference);
if (workspace == null) {
log("Could not add save participant as IWorkspace service is unavailable"); //$NON-NLS-1$
return null;
}
try {
InstanceScope.INSTANCE.getNode(ID_PLUGIN).flush();
} catch (BackingStoreException e) {
log(e);
workspace.addSaveParticipant(ID_PLUGIN, new ISaveParticipant() {
@Override
public void doneSaving(ISaveContext context1) {}
@Override
public void prepareToSave(ISaveContext context1) throws CoreException {}
@Override
public void rollback(ISaveContext context1) {}
@Override
public void saving(ISaveContext context1) throws CoreException {
try {
InstanceScope.INSTANCE.getNode(ID_PLUGIN).flush();
} catch (BackingStoreException e) {
log(e);
}
//catch in case any install times are still cached for removed JREs
writeInstallInfo();
}
});
} catch (CoreException e) {
log(e.getStatus());
context.ungetService(reference);
return null;
}
//catch in case any install times are still cached for removed JREs
writeInstallInfo();
return super.addingService(reference);
}
});

@Override
public void removedService(ServiceReference<IWorkspace> reference, IWorkspace service) {
service.removeSaveParticipant(ID_PLUGIN);
context.ungetService(reference);
}

};
fWorkspaceServiceTracker.open();

InstanceScope.INSTANCE.getNode(ID_PLUGIN).addPreferenceChangeListener(this);
JavaRuntime.addVMInstallChangedListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3315,6 +3315,16 @@ private static void initializeVMs() {
LaunchingPlugin.log(e);
}
}

boolean testsRunning = List.of(JavaCore.getClasspathVariableNames()).contains("TEST_LIB"); //$NON-NLS-1$
if (testsRunning) {
// Don't try to update compliance if JDT model tests are running,
// they need predictable defaults, not based on current JVM
// The classpath variable is contributed by org.eclipse.jdt.core.tests.model
// See https://github.com/eclipse-jdt/eclipse.jdt.core/issues/84
updateCompliance = false;
}

// update compliance if required
if (updateCompliance) {
updateCompliance(getDefaultVMInstall());
Expand All @@ -3335,13 +3345,7 @@ private static void updateCompliance(IVMInstall vm) {
String javaVersion = ((IVMInstall2)vm).getJavaVersion();
if (javaVersion != null) {
String compliance = null;
if (javaVersion.startsWith(JavaCore.VERSION_1_5)) {
compliance = JavaCore.VERSION_1_5;
} else if (javaVersion.startsWith(JavaCore.VERSION_1_6)) {
compliance = JavaCore.VERSION_1_6;
} else if (javaVersion.startsWith(JavaCore.VERSION_1_7)) {
compliance = JavaCore.VERSION_1_7;
} else if (javaVersion.startsWith(JavaCore.VERSION_1_8)) {
if (javaVersion.startsWith(JavaCore.VERSION_1_8)) {
compliance = JavaCore.VERSION_1_8;
} else if (javaVersion.startsWith(JavaCore.VERSION_9)
&& (javaVersion.length() == JavaCore.VERSION_9.length() || javaVersion.charAt(JavaCore.VERSION_9.length()) == '.')) {
Expand Down

0 comments on commit 375b57a

Please sign in to comment.