Skip to content

Commit 536efe9

Browse files
authored
Merge master to Beta Java 21 branch
2 parents 7757444 + 4613cf2 commit 536efe9

File tree

19 files changed

+97
-40
lines changed

19 files changed

+97
-40
lines changed

org.eclipse.jdt.debug.jdi.tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<artifactId>eclipse.jdt.debug</artifactId>
1616
<groupId>eclipse.jdt.debug</groupId>
17-
<version>4.28.0-SNAPSHOT</version>
17+
<version>4.29.0-SNAPSHOT</version>
1818
</parent>
1919
<groupId>org.eclipse.jdt</groupId>
2020
<artifactId>org.eclipse.jdt.debug.jdi.tests</artifactId>

org.eclipse.jdt.debug.tests/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<artifactId>eclipse.jdt.debug</artifactId>
1616
<groupId>eclipse.jdt.debug</groupId>
17-
<version>4.28.0-SNAPSHOT</version>
17+
<version>4.29.0-SNAPSHOT</version>
1818
</parent>
1919
<groupId>org.eclipse.jdt</groupId>
2020
<artifactId>org.eclipse.jdt.debug.tests</artifactId>

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ThreadNameChangeTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void testListenToThreadNameChange() throws Exception {
6565
IJavaLineBreakpoint bp2 = createLineBreakpoint(bpLine2, "", typeName + ".java", typeName);
6666
bp1.setSuspendPolicy(IJavaBreakpoint.SUSPEND_THREAD);
6767
bp2.setSuspendPolicy(IJavaBreakpoint.SUSPEND_THREAD);
68-
AtomicReference<List<DebugEvent>> events = new AtomicReference<>(new ArrayList<DebugEvent>());
68+
AtomicReference<List<DebugEvent>> events = new AtomicReference<>(new ArrayList<>());
6969
IDebugEventSetListener listener = new IDebugEventSetListener() {
7070
@Override
7171
public void handleDebugEvents(DebugEvent[] e) {
@@ -116,7 +116,7 @@ public void testListenToThreadNameChangeDisabled() throws Exception {
116116
IJavaLineBreakpoint bp2 = createLineBreakpoint(bpLine2, "", typeName + ".java", typeName);
117117
bp1.setSuspendPolicy(IJavaBreakpoint.SUSPEND_THREAD);
118118
bp2.setSuspendPolicy(IJavaBreakpoint.SUSPEND_THREAD);
119-
AtomicReference<List<DebugEvent>> events = new AtomicReference<>(new ArrayList<DebugEvent>());
119+
AtomicReference<List<DebugEvent>> events = new AtomicReference<>(new ArrayList<>());
120120
IDebugEventSetListener listener = new IDebugEventSetListener() {
121121
@Override
122122
public void handleDebugEvents(DebugEvent[] e) {

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/core/EventDispatcherTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public EventDispatcherTest(String name) {
4444
@Override
4545
protected void setUp() throws Exception {
4646
super.setUp();
47-
jobs = Collections.synchronizedMap(new IdentityHashMap<AbstractDispatchJob, Object>());
47+
jobs = Collections.synchronizedMap(new IdentityHashMap<>());
4848
jobListener = new JobChangeAdapter() {
4949
@Override
5050
public void aboutToRun(IJobChangeEvent event) {

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/ui/DetailPaneManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static Test suite() {
6666
* one or more detail panes are available.
6767
*/
6868
public void testGetUserPreferredDetailPane() {
69-
String id = fManager.getUserPreferredDetailPane(new HashSet<String>());
69+
String id = fManager.getUserPreferredDetailPane(new HashSet<>());
7070
assertNull("Incorrect pane ID", id);
7171

7272
Set<String> detailPanes = new HashSet<>();

org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
4242
org.eclipse.debug.ui;bundle-version="[3.13.400,4.0.0)",
4343
org.eclipse.jdt.debug;bundle-version="[3.20.0,4.0.0)",
4444
org.eclipse.jdt.launching;bundle-version="[3.19.0,4.0.0)",
45-
org.eclipse.jdt.ui;bundle-version="[3.27.0,4.0.0)",
45+
org.eclipse.jdt.ui;bundle-version="[3.29.0,4.0.0)",
4646
org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
4747
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
4848
org.eclipse.ui.console;bundle-version="[3.4.0,4.0.0)",

org.eclipse.jdt.debug.ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<parent>
1515
<artifactId>eclipse.jdt.debug</artifactId>
1616
<groupId>eclipse.jdt.debug</groupId>
17-
<version>4.28.0-SNAPSHOT</version>
17+
<version>4.29.0-SNAPSHOT</version>
1818
</parent>
1919
<groupId>org.eclipse.jdt</groupId>
2020
<artifactId>org.eclipse.jdt.debug.ui</artifactId>

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaApplicationLaunchShortcut.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2019 IBM Corporation and others.
2+
* Copyright (c) 2007, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -42,9 +42,12 @@
4242
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
4343
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
4444
import org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine;
45+
import org.eclipse.jdt.internal.ui.JavaPlugin;
4546
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
47+
import org.eclipse.jdt.ui.PreferenceConstants;
4648
import org.eclipse.jface.dialogs.MessageDialog;
4749
import org.eclipse.jface.operation.IRunnableContext;
50+
import org.eclipse.jface.preference.IPreferenceStore;
4851

4952
/**
5053
* Launch shortcut for local Java applications.
@@ -113,7 +116,10 @@ protected ILaunchConfiguration createConfiguration(IType type) {
113116
ILaunchConfigurationWorkingCopy wc = null;
114117
try {
115118
ILaunchConfigurationType configType = getConfigurationType();
116-
wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(type.getTypeQualifiedName('.')));
119+
IPreferenceStore preferenceStore = JavaPlugin.getDefault().getPreferenceStore();
120+
boolean useQualification = preferenceStore.getBoolean(PreferenceConstants.LAUNCH_NAME_FULLY_QUALIFIED_FOR_APPLICATION);
121+
String prefix = useQualification ? type.getFullyQualifiedName('.') : type.getTypeQualifiedName('.');
122+
wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(prefix));
117123
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName());
118124
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type.getJavaProject().getElementName());
119125
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MODULE_NAME, getModuleName(type));

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/JavaConnectTab.java

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 IBM Corporation and others.
2+
* Copyright (c) 2000, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,12 +13,12 @@
1313
*******************************************************************************/
1414
package org.eclipse.jdt.debug.ui.launchConfigurations;
1515

16+
import java.lang.reflect.InvocationTargetException;
1617
import java.util.HashMap;
1718
import java.util.Iterator;
1819
import java.util.List;
1920
import java.util.Map;
2021

21-
import org.eclipse.core.resources.IResource;
2222
import org.eclipse.core.resources.ResourcesPlugin;
2323
import org.eclipse.core.runtime.CoreException;
2424
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -27,19 +27,27 @@
2727
import org.eclipse.debug.ui.DebugUITools;
2828
import org.eclipse.debug.ui.IDebugUIConstants;
2929
import org.eclipse.jdi.internal.connect.ConnectMessages;
30+
import org.eclipse.jdt.core.IClassFile;
31+
import org.eclipse.jdt.core.ICompilationUnit;
3032
import org.eclipse.jdt.core.IJavaElement;
31-
import org.eclipse.jdt.core.JavaModelException;
33+
import org.eclipse.jdt.core.IMember;
34+
import org.eclipse.jdt.core.IType;
35+
import org.eclipse.jdt.core.search.IJavaSearchScope;
36+
import org.eclipse.jdt.core.search.SearchEngine;
3237
import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
3338
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
3439
import org.eclipse.jdt.internal.debug.ui.launcher.AbstractJavaMainTab;
3540
import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages;
41+
import org.eclipse.jdt.internal.debug.ui.launcher.MainMethodSearchEngine;
3642
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
3743
import org.eclipse.jdt.launching.IVMConnector;
3844
import org.eclipse.jdt.launching.JavaRuntime;
45+
import org.eclipse.jdt.ui.PreferenceConstants;
3946
import org.eclipse.jface.action.LegacyActionTools;
4047
import org.eclipse.jface.preference.BooleanFieldEditor;
4148
import org.eclipse.jface.preference.ComboFieldEditor;
4249
import org.eclipse.jface.preference.FieldEditor;
50+
import org.eclipse.jface.preference.IPreferenceStore;
4351
import org.eclipse.jface.preference.IntegerFieldEditor;
4452
import org.eclipse.jface.preference.PreferenceStore;
4553
import org.eclipse.jface.preference.StringFieldEditor;
@@ -318,22 +326,45 @@ public void setDefaults(ILaunchConfigurationWorkingCopy config) {
318326
*/
319327
private void initializeName(IJavaElement javaElement, ILaunchConfigurationWorkingCopy config) {
320328
String name = EMPTY_STRING;
321-
try {
322-
IResource resource = javaElement.getUnderlyingResource();
323-
if (resource != null) {
324-
name = resource.getName();
329+
if (javaElement instanceof IMember) {
330+
IMember member = (IMember)javaElement;
331+
if (member.isBinary()) {
332+
javaElement = member.getClassFile();
333+
}
334+
else {
335+
javaElement = member.getCompilationUnit();
336+
}
337+
}
338+
if (javaElement instanceof ICompilationUnit || javaElement instanceof IClassFile) {
339+
try {
340+
IJavaSearchScope scope = SearchEngine.createJavaSearchScope(new IJavaElement[] { javaElement }, false);
341+
MainMethodSearchEngine engine = new MainMethodSearchEngine();
342+
IType[] types = engine.searchMainMethods(getLaunchConfigurationDialog(), scope, false);
343+
if (types != null && (types.length > 0)) {
344+
// Simply grab the first main type found in the searched element and set the module name
345+
name = types[0].getFullyQualifiedName('.');
346+
}
347+
} catch (InterruptedException ie) {
348+
JDIDebugUIPlugin.log(ie);
349+
} catch (InvocationTargetException ite) {
350+
JDIDebugUIPlugin.log(ite);
351+
}
352+
if (name.isEmpty()) {
353+
name = javaElement.getElementName();
354+
}
355+
}
356+
if (name.length() > 0) {
357+
IPreferenceStore preferenceStore = PreferenceConstants.getPreferenceStore();
358+
boolean useQualification = preferenceStore.getBoolean(PreferenceConstants.LAUNCH_NAME_FULLY_QUALIFIED_FOR_APPLICATION);
359+
if (!useQualification) {
325360
int index = name.lastIndexOf('.');
326361
if (index > 0) {
327-
name = name.substring(0, index);
362+
name = name.substring(index + 1);
328363
}
329364
}
330-
else {
331-
name= javaElement.getElementName();
332-
}
333365
name = getLaunchConfigurationDialog().generateName(name);
366+
config.rename(name);
334367
}
335-
catch (JavaModelException jme) {JDIDebugUIPlugin.log(jme);}
336-
config.rename(name);
337368
}
338369

339370
/**

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/launcher/SharedJavaMainTab.java

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2019 IBM Corporation and others.
2+
* Copyright (c) 2005, 2023 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -32,7 +32,10 @@
3232
import org.eclipse.jdt.core.search.SearchEngine;
3333
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
3434
import org.eclipse.jdt.internal.debug.ui.actions.ControlAccessibleListener;
35+
import org.eclipse.jdt.internal.ui.JavaPlugin;
3536
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
37+
import org.eclipse.jdt.ui.PreferenceConstants;
38+
import org.eclipse.jface.preference.IPreferenceStore;
3639
import org.eclipse.swt.events.ModifyEvent;
3740
import org.eclipse.swt.events.ModifyListener;
3841
import org.eclipse.swt.events.SelectionEvent;
@@ -123,7 +126,7 @@ protected void initializeMainTypeAndName(IJavaElement javaElement, ILaunchConfig
123126
IType[] types = engine.searchMainMethods(getLaunchConfigurationDialog(), scope, false);
124127
if (types != null && (types.length > 0)) {
125128
// Simply grab the first main type found in the searched element and set the module name
126-
name = types[0].getFullyQualifiedName();
129+
name = types[0].getFullyQualifiedName('.');
127130
moduleName = getModuleName(types[0]);
128131

129132
}
@@ -137,9 +140,26 @@ protected void initializeMainTypeAndName(IJavaElement javaElement, ILaunchConfig
137140
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, name);
138141
config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MODULE_NAME, moduleName);
139142
if (name.length() > 0) {
140-
int index = name.lastIndexOf('.');
141-
if (index > 0) {
142-
name = name.substring(index + 1);
143+
String category = ""; //$NON-NLS-1$
144+
try {
145+
category = config.getType().getIdentifier();
146+
} catch (CoreException e) {
147+
// do nothing...we won't use qualified name in such a case
148+
}
149+
IPreferenceStore preferenceStore = JavaPlugin.getDefault().getPreferenceStore();
150+
boolean useQualification = false;
151+
if (category.equals("org.eclipse.jdt.launching.localJavaApplication")) { //$NON-NLS-1$ {
152+
useQualification = preferenceStore.getBoolean(PreferenceConstants.LAUNCH_NAME_FULLY_QUALIFIED_FOR_APPLICATION);
153+
} else if (category.equals("org.eclipse.jdt.launching.javaApplet")) { //$NON-NLS-1$
154+
useQualification = preferenceStore.getBoolean(PreferenceConstants.LAUNCH_NAME_FULLY_QUALIFIED_FOR_APPLET);
155+
} else if (category.equals("org.eclipse.jdt.junit.launchconfig")) { //$NON-NLS-1$
156+
useQualification = preferenceStore.getBoolean(PreferenceConstants.LAUNCH_NAME_FULLY_QUALIFIED_FOR_JUNIT_TEST);
157+
}
158+
if (!useQualification) {
159+
int index = name.lastIndexOf('.');
160+
if (index > 0) {
161+
name = name.substring(index + 1);
162+
}
143163
}
144164
name = getLaunchConfigurationDialog().generateName(name);
145165
config.rename(name);

0 commit comments

Comments
 (0)