Skip to content

Commit ef3dd53

Browse files
committed
Use Multi-Release Type for Caller implementation
The current implementation for Java 1.8 is rather complex because of only raw string info. With Java 9+ we can use StackWalker to perform faster and easier, to still retain compatibility with Java 1.8 we use a Multi-Release type here to use that implementation on any 9+ JVM.
1 parent 86c6465 commit ef3dd53

File tree

6 files changed

+50
-3
lines changed

6 files changed

+50
-3
lines changed
Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-9">
4+
<attributes>
5+
<attribute name="module" value="true"/>
6+
</attributes>
7+
</classpathentry>
48
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
59
<classpathentry kind="src" path="src"/>
10+
<classpathentry kind="src" path="src9">
11+
<attributes>
12+
<attribute name="release" value="9"/>
13+
</attributes>
14+
</classpathentry>
615
<classpathentry kind="output" path="bin"/>
716
</classpath>

ui/org.eclipse.pde.junit.runtime/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ org.eclipse.jdt.core.circularClasspath=error
88
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
99
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
1010
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
11+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
1112
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
1213
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
1314
org.eclipse.jdt.core.compiler.compliance=1.8

ui/org.eclipse.pde.junit.runtime/.settings/org.eclipse.pde.prefs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
compilers.f.unresolved-features=1
22
compilers.f.unresolved-plugins=1
3-
compilers.incompatible-environment=0
3+
compilers.incompatible-environment=2
44
compilers.p.build=1
55
compilers.p.build.bin.includes=1
66
compilers.p.build.encodings=2
@@ -12,14 +12,18 @@ compilers.p.build.source.library=1
1212
compilers.p.build.src.includes=1
1313
compilers.p.deprecated=1
1414
compilers.p.discouraged-class=1
15+
compilers.p.exec-env-too-low=2
16+
compilers.p.ignored-resource-protocols=
1517
compilers.p.internal=1
1618
compilers.p.matching-pom-version=0
1719
compilers.p.missing-packages=0
1820
compilers.p.missing-version-export-package=2
1921
compilers.p.missing-version-import-package=2
2022
compilers.p.missing-version-require-bundle=2
2123
compilers.p.no-required-att=0
24+
compilers.p.no.automatic.module=1
2225
compilers.p.not-externalized-att=1
26+
compilers.p.service.component.without.lazyactivation=1
2327
compilers.p.unknown-attribute=1
2428
compilers.p.unknown-class=1
2529
compilers.p.unknown-element=1

ui/org.eclipse.pde.junit.runtime/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Bundle-ActivationPolicy: lazy
1414
Import-Package: org.eclipse.ui.testing;resolution:=optional
1515
DynamicImport-Package: org.junit.platform.engine;version="[1.14.0,2.0.0)"
1616
Automatic-Module-Name: org.eclipse.pde.junit.runtime
17+
Multi-Release: true

ui/org.eclipse.pde.junit.runtime/src/org/eclipse/pde/internal/junit/runtime/Caller.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
/**
2626
* Default implementation used with Java 1.8
27-
* TODO provide MR variant using stack walker, currently blocked by JDT bug ...
2827
*/
2928
public class Caller {
3029

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Christoph Läubrich and others.
3+
* This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License 2.0
5+
* which accompanies this distribution, and is available at
6+
* https://www.eclipse.org/legal/epl-2.0/
7+
*
8+
* SPDX-License-Identifier: EPL-2.0
9+
*
10+
* Contributors:
11+
* Christoph Läubrich - initial API and implementation
12+
*
13+
*/
14+
package org.eclipse.pde.internal.junit.runtime;
15+
16+
import java.util.Objects;
17+
18+
import org.osgi.framework.Bundle;
19+
import org.osgi.framework.FrameworkUtil;
20+
21+
/**
22+
* Release specific implementation that using stack walker
23+
*/
24+
public class Caller {
25+
26+
private static final StackWalker WALKER = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
27+
private static final Bundle LOADER_BUNDLE = FrameworkUtil.getBundle(SPIBundleClassLoader.class);
28+
29+
static Bundle getBundle(int junitVersion) {
30+
return WALKER.walk(stream -> stream.map(sf -> FrameworkUtil.getBundle(sf.getDeclaringClass())).filter(Objects::nonNull).filter(b -> b != LOADER_BUNDLE).findFirst().orElse(null));
31+
}
32+
33+
}

0 commit comments

Comments
 (0)