Skip to content

Commit

Permalink
+ Ensure ClasspathJrt initialized to fix eclipse-jdt/eclipse.jdt.ui#1722
Browse files Browse the repository at this point in the history


+ Fix test's getJCL15PlusLibraryIfNeeded()
  • Loading branch information
stephan-herrmann committed Oct 17, 2024
1 parent 0b34789 commit e8fc652
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,13 @@ public static Classpath getClasspath(String classpathName, String encoding, Acce
return getClasspath(classpathName, encoding, false, accessRuleSet, null, options, release);
}
public static Classpath getJrtClasspath(String jdkHome, String encoding, AccessRuleSet accessRuleSet, Map<String, String> options) {
return new ClasspathJrt(new File(convertPathSeparators(jdkHome)), true, accessRuleSet, null);
ClasspathJrt classpathJrt = new ClasspathJrt(new File(convertPathSeparators(jdkHome)), true, accessRuleSet, null);
try {
classpathJrt.initialize();
} catch (IOException e) {
// Broken entry, but let clients have it anyway.
}
return classpathJrt;
}
public static Classpath getOlderSystemRelease(String jdkHome, String release, AccessRuleSet accessRuleSet) {
return isJRE12Plus ?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ protected void addClassFolder(IJavaProject javaProject, String folderRelativePat

}
protected void addExternalLibrary(IJavaProject javaProject, String jarPath, String[] pathAndContents, String[] nonJavaResources, String compliance) throws Exception {
String[] claspath = getJCL15PlusLibraryIfNeeded(compliance);
String[] claspath = getJCLLibrary(compliance);
org.eclipse.jdt.core.tests.util.Util.createJar(pathAndContents, nonJavaResources, jarPath, claspath, compliance);
addLibraryEntry(javaProject, new Path(jarPath), true/*exported*/);
}
Expand Down Expand Up @@ -742,7 +742,7 @@ protected IProject createLibrary(
IProject project = javaProject.getProject();
String projectLocation = project.getLocation().toOSString();
String jarPath = projectLocation + File.separator + jarName;
String[] claspath = getJCL15PlusLibraryIfNeeded(compliance);
String[] claspath = getJCLLibrary(compliance);
org.eclipse.jdt.core.tests.util.Util.createJar(pathAndContents, nonJavaResources, jarPath, claspath, compliance, options);
if (pathAndContents != null && pathAndContents.length != 0) {
String sourceZipPath = projectLocation + File.separator + sourceZipName;
Expand Down Expand Up @@ -2532,13 +2532,10 @@ public void ensureChildExists(IParent container, IJavaElement child) throws Java
}
}

protected String[] getJCL15PlusLibraryIfNeeded(String compliance) throws JavaModelException, IOException {
if (compliance.charAt(compliance.length()-1) >= '8' && (AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_8) != 0) {
// ensure that the JCL 18 lib is setup (i.e. that the jclMin18.jar is copied)
setUpJCLClasspathVariables("1.8");
return new String[] {getExternalJCLPathString("1.8")};
}
return null;
protected String[] getJCLLibrary(String compliance) throws JavaModelException, IOException {
// ensure that the requested JCL lib is setup (i.e. that the jclMinXY.jar is copied)
setUpJCLClasspathVariables(compliance);
return new String[] {getExternalJCLPathString(compliance)};
}
/**
* Returns the specified compilation unit in the given project, root, and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7455,7 +7455,7 @@ public void testBug576735a() throws Exception {
projectLocation + File.separator + "libMissing.jar");

// create another jar depending on libMissing.jar:
String[] classpath = getJCL15PlusLibraryIfNeeded("1.8");
String[] classpath = getJCLLibrary("1.8");
classpath = Arrays.copyOf(classpath, classpath.length+1);
classpath[classpath.length-1] = projectLocation + File.separator + "libMissing.jar";
Util.createJar(
Expand Down

0 comments on commit e8fc652

Please sign in to comment.