Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjay2018-09-25 09:49:34 +0000
committerjay2018-09-25 11:07:36 +0000
commit2a269a8600046558a3c0af2e8dcd9a733817dfd9 (patch)
tree1ff095b4188c851840a0e65c993a9344f7261a70 /org.eclipse.jdt.core
parent177cb806a4c65f88397c4aaf74b4028310714335 (diff)
downloadeclipse.jdt.core-2a269a8600046558a3c0af2e8dcd9a733817dfd9.tar.gz
eclipse.jdt.core-2a269a8600046558a3c0af2e8dcd9a733817dfd9.tar.xz
eclipse.jdt.core-2a269a8600046558a3c0af2e8dcd9a733817dfd9.zip
Bug 539421: [11] ClasspathMultiReleaseJar causes hang when compliance isI20180925-1800
less than 9 Change-Id: Id8574f1a4d9663301f21a3dda642280c874fddc0 Signed-off-by: jay <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.core')
-rw-r--r--org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java56
1 files changed, 30 insertions, 26 deletions
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
index 5776402482..25d07df967 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/builder/ClasspathMultiReleaseJar.java
@@ -100,38 +100,42 @@ public class ClasspathMultiReleaseJar extends ClasspathJar {
private static synchronized void initializeVersions(ClasspathMultiReleaseJar jar) {
Path filePath = Paths.get(jar.zipFilename);
- if (Files.exists(filePath)) {
- URI uri = URI.create("jar:" + filePath.toUri()); //$NON-NLS-1$
- try {
+ try {
+ if (Files.exists(filePath)) {
+ URI uri = URI.create("jar:" + filePath.toUri()); //$NON-NLS-1$
try {
- jar.fs = FileSystems.getFileSystem(uri);
- } catch (FileSystemNotFoundException e) {
- // move on
+ try {
+ jar.fs = FileSystems.getFileSystem(uri);
+ } catch (FileSystemNotFoundException e) {
+ // move on
+ }
+ if (jar.fs == null) {
+ jar.fs = FileSystems.newFileSystem(uri, new HashMap<>());
+ }
+ } catch (IllegalArgumentException | FileSystemNotFoundException | ProviderNotFoundException
+ | FileSystemAlreadyExistsException | IOException | SecurityException e) {
+ Util.log(e, "Failed to initialize versions for: " + jar); //$NON-NLS-1$
+ jar.supportedVersions = new Path[0];
}
if (jar.fs == null) {
- jar.fs = FileSystems.newFileSystem(uri, new HashMap<>());
+ return;
}
- } catch (IllegalArgumentException | FileSystemNotFoundException | ProviderNotFoundException
- | FileSystemAlreadyExistsException | IOException | SecurityException e) {
- Util.log(e, "Failed to initialize versions for: " + jar); //$NON-NLS-1$
- jar.supportedVersions = new Path[0];
- }
- if (jar.fs == null) {
- return;
- }
- jar.rootPath = jar.fs.getPath("/"); //$NON-NLS-1$
- int earliestJavaVersion = ClassFileConstants.MAJOR_VERSION_9;
- long latestJDK = CompilerOptions.releaseToJDKLevel(jar.compliance);
- int latestJavaVer = (int) (latestJDK >> 16);
- List<Path> versions = new ArrayList<>();
- for (int i = latestJavaVer; i >= earliestJavaVersion; i--) {
- Path path = jar.fs.getPath("/", "META-INF", "versions", "" + (i - 44)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (Files.exists(path)) {
- versions.add(jar.rootPath.relativize(path));
+ jar.rootPath = jar.fs.getPath("/"); //$NON-NLS-1$
+ int earliestJavaVersion = ClassFileConstants.MAJOR_VERSION_9;
+ long latestJDK = CompilerOptions.versionToJdkLevel(jar.compliance);
+ int latestJavaVer = (int) (latestJDK >> 16);
+ List<Path> versions = new ArrayList<>();
+ for (int i = latestJavaVer; i >= earliestJavaVersion; i--) {
+ Path path = jar.fs.getPath("/", "META-INF", "versions", "" + (i - 44)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ if (Files.exists(path)) {
+ versions.add(jar.rootPath.relativize(path));
+ }
}
+ jar.supportedVersions = versions.toArray(new Path[versions.size()]);
}
- jar.supportedVersions = versions.toArray(new Path[versions.size()]);
- if (jar.supportedVersions.length <= 0) {
+ } finally {
+ if ((jar.supportedVersions == null || jar.supportedVersions.length <= 0)
+ && (jar.fs != null && jar.fs.isOpen())) {
try {
jar.fs.close();
} catch (IOException e) {

Back to the top