Skip to content

Commit a208a02

Browse files
committed
Update Java2Script's JDT core to 3.11.1 v20150902, fixed bug of
compiling projects again and again.
1 parent 0fe713c commit a208a02

File tree

10 files changed

+75
-37
lines changed

10 files changed

+75
-37
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#Wed Aug 29 20:57:27 CST 2007
21
eclipse.preferences.version=1
3-
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
4-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
55
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6-
org.eclipse.jdt.core.compiler.compliance=1.4
6+
org.eclipse.jdt.core.compiler.compliance=1.5
77
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
88
org.eclipse.jdt.core.compiler.debug.localVariable=generate
99
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
10-
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
11-
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
12-
org.eclipse.jdt.core.compiler.source=1.3
10+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
11+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
12+
org.eclipse.jdt.core.compiler.source=1.5

sources/net.sf.j2s.core/build.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,3 @@ bin.includes = META-INF/,\
66
schema/
77
src.includes = META-INF/,\
88
plugin.xml
9-
javacSource = 1.3
10-
javacTarget = 1.2

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/AbstractImageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
* Provides the building and compilation mechanism
3838
* in common with the batch and incremental builders.
3939
*/
40+
@SuppressWarnings({ "rawtypes", "unchecked" })
4041
public abstract class AbstractImageBuilder implements ICompilerRequestor, ICompilationUnitLocator {
4142

4243
protected JavaBuilder javaBuilder;

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/BatchImageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.util.*;
2424

25+
@SuppressWarnings({ "rawtypes", "unchecked" })
2526
public class BatchImageBuilder extends AbstractImageBuilder {
2627

2728
IncrementalImageBuilder incrementalBuilder; // if annotations or secondary types have to be processed after the compile loop

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/ClasspathJar.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2010 IBM Corporation and others.
2+
* Copyright (c) 2000, 2015 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -8,6 +8,8 @@
88
* Contributors:
99
* IBM Corporation - initial API and implementation
1010
* Tal Lev-Ami - added package cache for zip files
11+
* Stephan Herrmann - Contribution for
12+
* Bug 440477 - [null] Infrastructure for feeding external annotations into compilation
1113
*******************************************************************************/
1214
package net.sf.j2s.core.builder;
1315

@@ -27,6 +29,7 @@
2729
import java.util.*;
2830
import java.util.zip.*;
2931

32+
@SuppressWarnings("rawtypes")
3033
public class ClasspathJar extends ClasspathLocation {
3134

3235
static class PackageCacheEntry {
@@ -80,12 +83,14 @@ static SimpleSet findPackageSet(ClasspathJar jar) {
8083
String zipFilename; // keep for equals
8184
IFile resource;
8285
ZipFile zipFile;
86+
ZipFile annotationZipFile;
8387
long lastModified;
8488
boolean closeZipFileAtEnd;
8589
SimpleSet knownPackageNames;
8690
AccessRuleSet accessRuleSet;
91+
String externalAnnotationPath;
8792

88-
ClasspathJar(IFile resource, AccessRuleSet accessRuleSet) {
93+
ClasspathJar(IFile resource, AccessRuleSet accessRuleSet, IPath externalAnnotationPath) {
8994
this.resource = resource;
9095
try {
9196
java.net.URI location = resource.getLocationURI();
@@ -101,31 +106,46 @@ static SimpleSet findPackageSet(ClasspathJar jar) {
101106
this.zipFile = null;
102107
this.knownPackageNames = null;
103108
this.accessRuleSet = accessRuleSet;
109+
if (externalAnnotationPath != null)
110+
this.externalAnnotationPath = externalAnnotationPath.toString();
104111
}
105112

106-
ClasspathJar(String zipFilename, long lastModified, AccessRuleSet accessRuleSet) {
113+
ClasspathJar(String zipFilename, long lastModified, AccessRuleSet accessRuleSet, IPath externalAnnotationPath) {
107114
this.zipFilename = zipFilename;
108115
this.lastModified = lastModified;
109116
this.zipFile = null;
110117
this.knownPackageNames = null;
111118
this.accessRuleSet = accessRuleSet;
119+
if (externalAnnotationPath != null)
120+
this.externalAnnotationPath = externalAnnotationPath.toString();
112121
}
113122

114-
public ClasspathJar(ZipFile zipFile, AccessRuleSet accessRuleSet) {
123+
public ClasspathJar(ZipFile zipFile, AccessRuleSet accessRuleSet, IPath externalAnnotationPath) {
115124
this.zipFilename = zipFile.getName();
116125
this.zipFile = zipFile;
117126
this.closeZipFileAtEnd = false;
118127
this.knownPackageNames = null;
119128
this.accessRuleSet = accessRuleSet;
129+
if (externalAnnotationPath != null)
130+
this.externalAnnotationPath = externalAnnotationPath.toString();
120131
}
121132

122133
public void cleanup() {
123-
if (this.zipFile != null && this.closeZipFileAtEnd) {
124-
try {
125-
this.zipFile.close();
126-
} catch(IOException e) { // ignore it
134+
if (this.closeZipFileAtEnd) {
135+
if (this.zipFile != null) {
136+
try {
137+
this.zipFile.close();
138+
} catch(IOException e) { // ignore it
139+
}
140+
this.zipFile = null;
141+
}
142+
if (this.annotationZipFile != null) {
143+
try {
144+
this.annotationZipFile.close();
145+
} catch(IOException e) { // ignore it
146+
}
147+
this.annotationZipFile = null;
127148
}
128-
this.zipFile = null;
129149
}
130150
this.knownPackageNames = null;
131151
}
@@ -147,9 +167,16 @@ public NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPa
147167
try {
148168
ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
149169
if (reader != null) {
170+
String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
171+
if (this.externalAnnotationPath != null) {
172+
try {
173+
this.annotationZipFile = reader.setExternalAnnotationProvider(this.externalAnnotationPath, fileNameWithoutExtension, this.annotationZipFile, null);
174+
} catch (IOException e) {
175+
// don't let error on annotations fail class reading
176+
}
177+
}
150178
if (this.accessRuleSet == null)
151179
return new NameEnvironmentAnswer(reader, null);
152-
String fileNameWithoutExtension = qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
153180
return new NameEnvironmentAnswer(reader, this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
154181
}
155182
} catch (IOException e) { // treat as if class file is missing

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/ClasspathLocation.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2012 IBM Corporation and others.
2+
* Copyright (c) 2000, 2015 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
66
* http://www.eclipse.org/legal/epl-v10.html
77
*
88
* Contributors:
99
* IBM Corporation - initial API and implementation
10+
* Stephan Herrmann - Contribution for
11+
* Bug 440477 - [null] Infrastructure for feeding external annotations into compilation
1012
*******************************************************************************/
1113
package net.sf.j2s.core.builder;
1214

@@ -26,16 +28,16 @@ public static ClasspathLocation forBinaryFolder(IContainer binaryFolder, boolean
2628
return new ClasspathDirectory(binaryFolder, isOutputFolder, accessRuleSet);
2729
}
2830

29-
static ClasspathLocation forLibrary(String libraryPathname, long lastModified, AccessRuleSet accessRuleSet) {
30-
return new ClasspathJar(libraryPathname, lastModified, accessRuleSet);
31+
static ClasspathLocation forLibrary(String libraryPathname, long lastModified, AccessRuleSet accessRuleSet, IPath annotationsPath) {
32+
return new ClasspathJar(libraryPathname, lastModified, accessRuleSet, annotationsPath);
3133
}
3234

33-
static ClasspathLocation forLibrary(String libraryPathname, AccessRuleSet accessRuleSet) {
34-
return forLibrary(libraryPathname, 0, accessRuleSet);
35+
static ClasspathLocation forLibrary(String libraryPathname, AccessRuleSet accessRuleSet, IPath annotationsPath) {
36+
return forLibrary(libraryPathname, 0, accessRuleSet, annotationsPath);
3537
}
3638

37-
static ClasspathLocation forLibrary(IFile library, AccessRuleSet accessRuleSet) {
38-
return new ClasspathJar(library, accessRuleSet);
39+
static ClasspathLocation forLibrary(IFile library, AccessRuleSet accessRuleSet, IPath annotationsPath) {
40+
return new ClasspathJar(library, accessRuleSet, annotationsPath);
3941
}
4042

4143
public abstract NameEnvironmentAnswer findClass(String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName);

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/IncrementalImageBuilder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/**
3232
* The incremental image builder
3333
*/
34+
@SuppressWarnings({"rawtypes", "unchecked"})
3435
public class IncrementalImageBuilder extends AbstractImageBuilder {
3536

3637
protected ArrayList sourceFiles;

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/JavaBuilder.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2013 IBM Corporation and others.
2+
* Copyright (c) 2000, 2014 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
66
* http://www.eclipse.org/legal/epl-v10.html
77
*
88
* Contributors:
99
* IBM Corporation - initial API and implementation
10+
* Terry Parker <tparker@google.com> - [performance] Low hit rates in JavaModel caches - https://bugs.eclipse.org/421165
1011
*******************************************************************************/
1112
package net.sf.j2s.core.builder;
1213

1314
import org.eclipse.core.resources.*;
1415
import org.eclipse.core.runtime.*;
16+
1517
import org.eclipse.jdt.core.*;
1618
import org.eclipse.jdt.core.compiler.*;
1719
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
@@ -20,10 +22,9 @@
2022
import org.eclipse.jdt.internal.core.util.Util;
2123

2224
import java.io.*;
23-
import java.lang.reflect.InvocationTargetException;
24-
import java.lang.reflect.Method;
2525
import java.util.*;
2626

27+
@SuppressWarnings({"rawtypes", "unchecked"})
2728
public class JavaBuilder extends IncrementalProjectBuilder {
2829

2930
IProject currentProject;
@@ -792,7 +793,7 @@ private void recordNewState(State state) {
792793
if (DEBUG)
793794
System.out.println("JavaBuilder: Recording new state : " + state); //$NON-NLS-1$
794795
// state.dump();
795-
JavaModelManager.getJavaModelManager().setLastBuiltState(currentProject, newState);
796+
JavaModelManager.getJavaModelManager().setLastBuiltState(this.currentProject, newState);
796797
}
797798

798799
/**

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/NameEnvironment.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2012 IBM Corporation and others.
2+
* Copyright (c) 2000, 2015 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
@@ -12,6 +12,7 @@
1212
* - Another problem with inner classes referenced from jars or class folders: "The type ... cannot be resolved"
1313
* Stephan Herrmann - Contribution for
1414
* Bug 392727 - Cannot compile project when a java file contains $ in its file name
15+
* Bug 440477 - [null] Infrastructure for feeding external annotations into compilation
1516
*******************************************************************************/
1617
package net.sf.j2s.core.builder;
1718

@@ -30,6 +31,7 @@
3031
import java.io.*;
3132
import java.util.*;
3233

34+
@SuppressWarnings({"rawtypes", "unchecked"})
3335
public class NameEnvironment implements INameEnvironment, SuffixConstants {
3436

3537
boolean isIncrementalBuild;
@@ -102,6 +104,7 @@ private void computeClasspathLocations(
102104
ClasspathEntry entry = (ClasspathEntry) classpathEntries[i];
103105
IPath path = entry.getPath();
104106
Object target = JavaModel.getTarget(path, true);
107+
IPath externalAnnotationPath = ClasspathEntry.getExternalAnnotationPath(entry, javaProject.getProject(), true);
105108
if (target == null) continue nextEntry;
106109

107110
switch(entry.getEntryKind()) {
@@ -171,7 +174,7 @@ private void computeClasspathLocations(
171174
&& JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true)))
172175
? null
173176
: entry.getAccessRuleSet();
174-
bLocation = ClasspathLocation.forLibrary((IFile) resource, accessRuleSet);
177+
bLocation = ClasspathLocation.forLibrary((IFile) resource, accessRuleSet, externalAnnotationPath);
175178
} else if (resource instanceof IContainer) {
176179
AccessRuleSet accessRuleSet =
177180
(JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_FORBIDDEN_REFERENCE, true))
@@ -199,7 +202,7 @@ private void computeClasspathLocations(
199202
&& JavaCore.IGNORE.equals(javaProject.getOption(JavaCore.COMPILER_PB_DISCOURAGED_REFERENCE, true)))
200203
? null
201204
: entry.getAccessRuleSet();
202-
bLocations.add(ClasspathLocation.forLibrary(path.toString(), accessRuleSet));
205+
bLocations.add(ClasspathLocation.forLibrary(path.toString(), accessRuleSet, externalAnnotationPath));
203206
}
204207
continue nextEntry;
205208
}

sources/net.sf.j2s.core/src/net/sf/j2s/core/builder/State.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2012 IBM Corporation and others.
2+
* Copyright (c) 2000, 2014 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License v1.0
55
* which accompanies this distribution, and is available at
66
* http://www.eclipse.org/legal/epl-v10.html
77
*
88
* Contributors:
99
* IBM Corporation - initial API and implementation
10+
* Stephan Herrmann - Contribution for
11+
* Bug 440477 - [null] Infrastructure for feeding external annotations into compilation
1012
*******************************************************************************/
1113
package net.sf.j2s.core.builder;
1214

@@ -23,6 +25,7 @@
2325
import java.io.*;
2426
import java.util.*;
2527

28+
@SuppressWarnings({"rawtypes", "unchecked"})
2629
public class State {
2730
// NOTE: this state cannot contain types that are not defined in this project
2831

@@ -44,7 +47,7 @@ public class State {
4447
private StringSet structurallyChangedTypes;
4548
public static int MaxStructurallyChangedTypes = 100; // keep track of ? structurally changed types, otherwise consider all to be changed
4649

47-
public static final byte VERSION = 0x001B;
50+
public static final byte VERSION = 0x001C;
4851

4952
static final byte SOURCE_FOLDER = 1;
5053
static final byte BINARY_FOLDER = 2;
@@ -268,10 +271,10 @@ static State read(IProject project, DataInputStream in) throws IOException {
268271
newState.binaryLocations[i] = ClasspathLocation.forBinaryFolder(outputFolder, in.readBoolean(), readRestriction(in));
269272
break;
270273
case EXTERNAL_JAR :
271-
newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF(), in.readLong(), readRestriction(in));
274+
newState.binaryLocations[i] = ClasspathLocation.forLibrary(in.readUTF(), in.readLong(), readRestriction(in), new Path(in.readUTF()));
272275
break;
273276
case INTERNAL_JAR :
274-
newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())), readRestriction(in));
277+
newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())), readRestriction(in), new Path(in.readUTF()));
275278
}
276279
}
277280

@@ -462,6 +465,7 @@ void write(DataOutputStream out) throws IOException {
462465
out.writeUTF(jar.resource.getFullPath().toString());
463466
}
464467
writeRestriction(jar.accessRuleSet, out);
468+
out.writeUTF(jar.externalAnnotationPath != null ? jar.externalAnnotationPath : ""); //$NON-NLS-1$
465469
}
466470
}
467471

0 commit comments

Comments
 (0)