diff options
39 files changed, 369 insertions, 82 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java index 37b727175..64e53eead 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/JavadocRunner.java @@ -14,11 +14,16 @@ package org.aspectj.tools.ajdoc; -import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.List; +import java.util.Vector; -import org.aspectj.util.LangUtil; +import javax.tools.DocumentationTool; +import javax.tools.DocumentationTool.DocumentationTask; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; /** * @author Mik Kersten @@ -66,11 +71,6 @@ class JavadocRunner { // } // } ); - // Need to do something different on Java > 9 due to removal of standard doclet I think -// if (LangUtil.is19VMOrGreater()) { -// // Not visible according to module rules... -// clazz = Class.forName("jdk.javadoc.internal.tool.Main"); -// } try { // for JDK 1.4 and above call the execute method... Class jdMainClass = com.sun.tools.javadoc.Main.class; @@ -100,4 +100,13 @@ class JavadocRunner { // Set the security manager back // System.setSecurityManager(defaultSecurityManager); } + + public static void callJavadocViaToolProvider(Vector<String> options, List<String> files) { + DocumentationTool doctool = ToolProvider.getSystemDocumentationTool(); + StandardJavaFileManager fm = doctool.getStandardFileManager(null, null, null); + Iterable<? extends JavaFileObject> jfos = fm.getJavaFileObjects(files.toArray(new String[0])); + DocumentationTask task = doctool.getTask(null/*standard System.err*/, null/*standard file manager*/, + null/*default diagnostic listener*/, null/*standard doclet*/, options, jfos); + task.call(); + } } diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java index e8f1472b5..2e622ba9c 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java @@ -35,6 +35,7 @@ import org.aspectj.asm.AsmManager; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.Version; import org.aspectj.util.FileUtil; +import org.aspectj.util.LangUtil; /** * This is an old implementation of ajdoc that does not use an OO style. However, it does the job, and should serve to evolve a @@ -125,7 +126,7 @@ public class Main implements Config { } for (int i = 0; i < filenames.size(); i++) { - inputFiles[i] = new File((String) filenames.elementAt(i)); + inputFiles[i] = new File(filenames.elementAt(i)); } // PHASE 0: call ajc @@ -223,7 +224,7 @@ public class Main implements Config { String[] argsToCompiler = new String[ajcOptions.size() + inputFiles.length]; int i = 0; for (; i < ajcOptions.size(); i++) { - argsToCompiler[i] = (String) ajcOptions.elementAt(i); + argsToCompiler[i] = ajcOptions.elementAt(i); } for (int j = 0; j < inputFiles.length; j++) { argsToCompiler[i] = inputFiles[j].getAbsolutePath(); @@ -237,6 +238,8 @@ public class Main implements Config { private static void callJavadoc(File[] signatureFiles) throws IOException { System.out.println("> Calling javadoc..."); String[] javadocargs = null; + + List<String> files = new ArrayList<String>(); if (packageMode) { int numExtraArgs = 2; if (authorStandardDocletSwitch) @@ -256,24 +259,37 @@ public class Main implements Config { } // javadocargs[1] = getSourcepathAsString(); for (int k = 0; k < options.size(); k++) { - javadocargs[numExtraArgs + k] = (String) options.elementAt(k); + javadocargs[numExtraArgs + k] = options.elementAt(k); } for (int k = 0; k < packageList.size(); k++) { - javadocargs[numExtraArgs + options.size() + k] = (String) packageList.elementAt(k); + javadocargs[numExtraArgs + options.size() + k] = packageList.elementAt(k); } for (int k = 0; k < fileList.size(); k++) { - javadocargs[numExtraArgs + options.size() + packageList.size() + k] = (String) fileList.elementAt(k); + javadocargs[numExtraArgs + options.size() + packageList.size() + k] = fileList.elementAt(k); + } + if (LangUtil.is19VMOrGreater()) { + options = new Vector<String>(); + for (String a: javadocargs) { + options.add(a); + } } } else { javadocargs = new String[options.size() + signatureFiles.length]; for (int k = 0; k < options.size(); k++) { - javadocargs[k] = (String) options.elementAt(k); + javadocargs[k] = options.elementAt(k); } for (int k = 0; k < signatureFiles.length; k++) { javadocargs[options.size() + k] = StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath()); } + for (int k = 0; k < signatureFiles.length; k++) { + files.add(StructureUtil.translateAjPathName(signatureFiles[k].getCanonicalPath())); + } + } + if (LangUtil.is19VMOrGreater()) { + JavadocRunner.callJavadocViaToolProvider(options, files); + } else { + JavadocRunner.callJavadoc(javadocargs); } - JavadocRunner.callJavadoc(javadocargs); } /** @@ -290,7 +306,7 @@ public class Main implements Config { removeDeclIDsFromFile("serialized-form.html", true); if (packageList.size() > 0) { for (int p = 0; p < packageList.size(); p++) { - removeDeclIDsFromFile(((String) packageList.elementAt(p)).replace('.', '/') + Config.DIR_SEP_CHAR + removeDeclIDsFromFile(packageList.elementAt(p).replace('.', '/') + Config.DIR_SEP_CHAR + "package-summary.html", true); } } else { @@ -300,6 +316,7 @@ public class Main implements Config { return; } files = FileUtil.listFiles(rootDir, new FileFilter() { + @Override public boolean accept(File f) { return f.getName().equals("package-summary.html"); } @@ -348,7 +365,7 @@ public class Main implements Config { Vector<String> sourcePath = new Vector<String>(); boolean found = false; for (int i = 0; i < options.size(); i++) { - String currOption = (String) options.elementAt(i); + String currOption = options.elementAt(i); if (found && !currOption.startsWith("-")) { sourcePath.add(currOption); } @@ -362,8 +379,8 @@ public class Main implements Config { static File getRootDir() { File rootDir = new File("."); for (int i = 0; i < options.size(); i++) { - if (((String) options.elementAt(i)).equals("-d")) { - rootDir = new File((String) options.elementAt(i + 1)); + if (options.elementAt(i).equals("-d")) { + rootDir = new File(options.elementAt(i + 1)); if (!rootDir.exists()) { rootDir.mkdir(); // System.out.println( "Destination directory not found: " + @@ -462,7 +479,7 @@ public class Main implements Config { args = new String[argList.size()]; int counter = 0; for (Iterator<String> it = argList.iterator(); it.hasNext();) { - args[counter] = (String) it.next(); + args[counter] = it.next(); counter++; } } catch (FileNotFoundException e) { @@ -494,7 +511,7 @@ public class Main implements Config { static String getSourcepathAsString() { String cPath = ""; for (int i = 0; i < sourcepath.size(); i++) { - cPath += (String) sourcepath.elementAt(i) + Config.DIR_SEP_CHAR + outputWorkingDir; + cPath += sourcepath.elementAt(i) + Config.DIR_SEP_CHAR + outputWorkingDir; if (i != sourcepath.size() - 1) { cPath += File.pathSeparator; } @@ -667,10 +684,11 @@ public class Main implements Config { // do this for every item in the classpath for (int c = 0; c < sourcepath.size(); c++) { - String path = (String) sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg; + String path = sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg; File pkg = new File(path); if (pkg.isDirectory()) { String[] files = pkg.list(new FilenameFilter() { + @Override public boolean accept(File dir, String name) { int index1 = name.lastIndexOf("."); int index2 = name.length(); @@ -684,7 +702,7 @@ public class Main implements Config { } }); for (int j = 0; j < files.length; j++) { - filenames.addElement((String) sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg + filenames.addElement(sourcepath.elementAt(c) + Config.DIR_SEP_CHAR + arg + Config.DIR_SEP_CHAR + files[j]); } } else if (c == sourcepath.size()) { // last element on classpath diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java index ea9a81875..e3674086e 100644 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java +++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java @@ -15,12 +15,12 @@ import java.io.IOException; import java.util.Iterator; import java.util.List; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; - import org.aspectj.tools.ajc.Ajc; import org.aspectj.util.LangUtil; +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; + /** * This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over * the test projects and running the ajdoc command @@ -31,6 +31,7 @@ public class AjdocTestCase extends TestCase { protected static File sandboxDir; private String docOutdir, projectDir; + @Override protected void setUp() throws Exception { super.setUp(); docOutdir = null; @@ -41,6 +42,7 @@ public class AjdocTestCase extends TestCase { Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath()); } + @Override protected void tearDown() throws Exception { super.tearDown(); // reset where ajdocworkingdir is created @@ -166,7 +168,8 @@ public class AjdocTestCase extends TestCase { !sourceLevel.equals("1.6") && !sourceLevel.equals("1.7") && !sourceLevel.equals("1.8") && - !sourceLevel.equals("1.9")) { + !sourceLevel.equals("1.9") && + !sourceLevel.equals("10")) { fail("need to pass ajdoc '1.3' > '1.9' as the source level"); } String[] args = new String[6 + inputFiles.length + ajOptions.length]; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java index 85abecff7..a5068f638 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/Constants.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/Constants.java @@ -82,6 +82,8 @@ public interface Constants { public final static short MINOR_1_8 = 0; public final static short MAJOR_1_9 = 53; public final static short MINOR_1_9 = 0; + public final static short MAJOR_10 = 54; + public final static short MINOR_10 = 0; // Defaults public final static short MAJOR = MAJOR_1_1; public final static short MINOR = MINOR_1_1; diff --git a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java index 0f5df2d4d..136f69390 100644 --- a/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java +++ b/bcel-builder/src/org/aspectj/apache/bcel/util/ClassPath.java @@ -53,20 +53,29 @@ */ package org.aspectj.apache.bcel.util; -import java.util.*; -import java.util.zip.*; - -import java.io.*; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FilenameFilter; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; import java.net.URI; -import java.nio.file.FileVisitResult; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.DirectoryStream; import java.nio.file.FileSystems; +import java.nio.file.FileVisitResult; import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; /** * Responsible for loading (class) files from the CLASSPATH. Inspired by @@ -131,6 +140,7 @@ public class ClassPath implements Serializable { * * @deprecated Use SYSTEM_CLASS_PATH constant */ + @Deprecated public ClassPath() { this(getClassPath()); } @@ -138,14 +148,17 @@ public class ClassPath implements Serializable { /** * @return used class path string */ + @Override public String toString() { return class_path; } + @Override public int hashCode() { return class_path.hashCode(); } + @Override public boolean equals(Object o) { if (o instanceof ClassPath) { return class_path.equals(((ClassPath) o).class_path); @@ -191,6 +204,7 @@ public class ClassPath implements Serializable { for (Iterator<String> e = dirs.iterator(); e.hasNext();) { File ext_dir = new File(e.next()); String[] extensions = ext_dir.list(new FilenameFilter() { + @Override public boolean accept(File dir, String name) { name = name.toLowerCase(); return name.endsWith(".zip") || name.endsWith(".jar"); @@ -212,7 +226,7 @@ public class ClassPath implements Serializable { } // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem - if (vm_version.startsWith("9")) { + if (vm_version.startsWith("9") || vm_version.startsWith("10")) { buf.insert(0, File.pathSeparatorChar); buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS); } @@ -378,14 +392,17 @@ public class ClassPath implements Serializable { dir = d; } + @Override ClassFile getClassFile(String name, String suffix) throws IOException { final File file = new File(dir + File.separatorChar + name.replace('.', File.separatorChar) + suffix); return file.exists() ? new ClassFile() { + @Override public InputStream getInputStream() throws IOException { return new FileInputStream(file); } + @Override public String getPath() { try { return file.getCanonicalPath(); @@ -395,14 +412,17 @@ public class ClassPath implements Serializable { } + @Override public long getTime() { return file.lastModified(); } + @Override public long getSize() { return file.length(); } + @Override public String getBase() { return dir; } @@ -410,6 +430,7 @@ public class ClassPath implements Serializable { } : null; } + @Override public String toString() { return dir; } @@ -472,30 +493,36 @@ public class ClassPath implements Serializable { this.size = size; } + @Override public InputStream getInputStream() throws IOException { // TODO too costly to keep these in inflated form in memory? this.bais = new ByteArrayInputStream(bytes); return this.bais; } + @Override public String getPath() { return this.path; } + @Override public String getBase() { return this.base; } + @Override public long getTime() { return this.time; } + @Override public long getSize() { return this.size; } } + @Override ClassFile getClassFile(String name, String suffix) throws IOException { // Class files are in here under names like this: // /modules/java.base/java/lang/Object.class (jdk9 b74) @@ -522,26 +549,32 @@ public class ClassPath implements Serializable { zip = z; } + @Override ClassFile getClassFile(String name, String suffix) throws IOException { final ZipEntry entry = zip.getEntry(name.replace('.', '/') + suffix); return (entry != null) ? new ClassFile() { + @Override public InputStream getInputStream() throws IOException { return zip.getInputStream(entry); } + @Override public String getPath() { return entry.toString(); } + @Override public long getTime() { return entry.getTime(); } + @Override public long getSize() { return entry.getSize(); } + @Override public String getBase() { return zip.getName(); } diff --git a/lib/asm/asm-6.0.jar b/lib/asm/asm-6.0.jar Binary files differdeleted file mode 100644 index cf2de272c..000000000 --- a/lib/asm/asm-6.0.jar +++ /dev/null diff --git a/lib/asm/asm-6.0.renamed.jar b/lib/asm/asm-6.0.renamed.jar Binary files differdeleted file mode 100644 index c84e3563a..000000000 --- a/lib/asm/asm-6.0.renamed.jar +++ /dev/null diff --git a/lib/asm/asm-6.1.1.jar b/lib/asm/asm-6.1.1.jar Binary files differnew file mode 100644 index 000000000..35b934d69 --- /dev/null +++ b/lib/asm/asm-6.1.1.jar diff --git a/lib/asm/asm-6.1.1.renamed.jar b/lib/asm/asm-6.1.1.renamed.jar Binary files differnew file mode 100644 index 000000000..3f99d226f --- /dev/null +++ b/lib/asm/asm-6.1.1.renamed.jar diff --git a/lib/asm/build.xml b/lib/asm/build.xml index fdd569cce..5aa6f88e1 100644 --- a/lib/asm/build.xml +++ b/lib/asm/build.xml @@ -4,8 +4,8 @@ <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"/> <target name="package" description="Jarjar asm-5.0.4.jar and prefix package name with aj"> - <jarjar destfile="asm-6.0.renamed.jar"> - <zipfileset src="asm-6.0.jar" excludes="module-info.class"/> + <jarjar destfile="asm-6.1.1.renamed.jar"> + <zipfileset src="asm-6.1.1.jar" excludes="module-info.class"/> <rule pattern="org.objectweb.asm.**" result="aj.org.objectweb.asm.@1"/> </jarjar> </target> diff --git a/lib/bcel/bcel-src.zip b/lib/bcel/bcel-src.zip Binary files differindex b98e0889e..5cf1d1b02 100644 --- a/lib/bcel/bcel-src.zip +++ b/lib/bcel/bcel-src.zip diff --git a/lib/bcel/bcel-verifier.jar b/lib/bcel/bcel-verifier.jar Binary files differindex cee235ad9..27e88cef5 100644 --- a/lib/bcel/bcel-verifier.jar +++ b/lib/bcel/bcel-verifier.jar diff --git a/lib/bcel/bcel.jar b/lib/bcel/bcel.jar Binary files differindex 793bf0d0d..5d1ad474e 100644 --- a/lib/bcel/bcel.jar +++ b/lib/bcel/bcel.jar diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java index 032719165..448618c11 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -832,11 +832,15 @@ public class BuildArgParser extends Main { } else if (arg.equals("-1.9")) { buildConfig.setBehaveInJava5Way(true); unparsedArgs.add("-1.9"); + } else if (arg.equals("-10")) { + buildConfig.setBehaveInJava5Way(true); + unparsedArgs.add("-10"); } else if (arg.equals("-source")) { if (args.size() > nextArgIndex) { String level = args.get(nextArgIndex).getValue(); if (level.equals("1.5") || level.equals("5") || level.equals("1.6") || level.equals("6") || level.equals("1.7") - || level.equals("7") || level.equals("8") || level.equals("1.8") || level.equals("9") || level.equals("1.9")) { + || level.equals("7") || level.equals("8") || level.equals("1.8") + || level.equals("9") || level.equals("1.9") || level.equals("10")) { buildConfig.setBehaveInJava5Way(true); } unparsedArgs.add("-source"); diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java index 0590df712..f2a938c4e 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AjMethodDeclaration.java @@ -56,9 +56,10 @@ public class AjMethodDeclaration extends MethodDeclaration { return classFile.generateMethodInfoAttributes(binding,extras); } + @Override protected int generateInfoAttributes(ClassFile classFile) { return generateInfoAttributes(classFile,false); - } + } protected void addDeclarationStartLineAttribute(List extraAttributeList, ClassFile classFile) { if ((classFile.codeStream.generateAttributes & ClassFileConstants.ATTR_LINES)==0) return; diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java index 3355c94c9..fc0d42154 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java @@ -22,14 +22,12 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Argument; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; -import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeParameter; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.Opcodes; import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowContext; import org.aspectj.org.eclipse.jdt.internal.compiler.flow.FlowInfo; -import org.aspectj.org.eclipse.jdt.internal.compiler.flow.InitializationFlowContext; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; @@ -59,9 +57,10 @@ import org.aspectj.weaver.UnresolvedType; */ public class InterTypeMethodDeclaration extends InterTypeDeclaration { public InterTypeMethodDeclaration(CompilationResult result, TypeReference onType) { - super(result, onType); + super(result, onType); } + @Override public void parseStatements(Parser parser, CompilationUnitDeclaration unit) { if (ignoreFurtherInvestigation) return; @@ -70,6 +69,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { } } + @Override protected char[] getPrefix() { return (NameMangler.ITD_PREFIX + "interMethod$").toCharArray(); } @@ -91,6 +91,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { super.analyseCode(classScope, flowContext, flowInfo); } + @Override public void resolve(ClassScope upperScope) { if (munger == null) ignoreFurtherInvestigation = true; @@ -119,6 +120,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { super.resolve(upperScope); } + @Override public void resolveStatements() { checkAndSetModifiersForMethod(); if ((modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) { @@ -196,6 +198,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { } } + @Override public EclipseTypeMunger build(ClassScope classScope) { EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(classScope); @@ -241,6 +244,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { return new AjAttribute.TypeMunger(munger); } + @Override public void generateCode(ClassScope classScope, ClassFile classFile) { if (ignoreFurtherInvestigation) { // System.err.println("no code for " + this); @@ -339,6 +343,7 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber); } + @Override protected Shadow.Kind getShadowKindForBody() { return Shadow.MethodExecution; } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 975235918..c9ce44abf 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -997,7 +997,12 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour units[i] = moduleCU; } else { units[i] = new CompilationUnit(null, filenames[i], defaultEncoding, null, false, moduleName); - units[i].setModule(moduleCU); + // With Java 10 changes the modulebinding is fetched from the rootenvironment + // this.moduleBinding = rootEnvironment.getModule(this.module); + // rather than using the moduleCU: + // if (this.modCU != null) + // return this.moduleBinding = this.modCU.module(rootEnvironment); +// units[i].setModule(moduleCU); } // new CompilationUnit(null, fileName, encoding, this.destinationPaths[i], // shouldIgnoreOptionalProblems(this.ignoreOptionalProblemsFromFolders, fileName.toCharArray()), diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index 8014e5ff7..30bc1165b 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -2227,7 +2227,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (qualifiedNames.length < qualifiedStrings.elementSize) { qualifiedNames = null; } - char[][] simpleNames = ReferenceCollection.internSimpleNames(simpleStrings); + char[][] simpleNames = ReferenceCollection.internSimpleNames(simpleStrings, true); // if a well known name was found then we can skip over these if (simpleNames.length < simpleStrings.elementSize) { simpleNames = null; diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java index 302739e71..e88ae0251 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java @@ -91,7 +91,7 @@ public class AjcTestCase extends TestCase { + File.separator + "bcel-verifier.jar" - + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-6.0.renamed.jar" + + File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-6.1.1.renamed.jar" // When the build machine executes the tests, it is using code built into jars rather than code build into // bin directories. This means for the necessary types to be found we have to put these jars on the classpath: diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip Binary files differindex 6fd88f22c..17eba397b 100644 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip +++ b/org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip diff --git a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar Binary files differindex 577b4be39..270837a87 100644 --- a/org.eclipse.jdt.core/jdtcore-for-aspectj.jar +++ b/org.eclipse.jdt.core/jdtcore-for-aspectj.jar diff --git a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java index 1bbab168a..93f93ef47 100644 --- a/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java +++ b/taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java @@ -254,9 +254,9 @@ public class AjcTask extends MatchingTask { public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR"; - static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9" }; - static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9" }; - static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9" }; + static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10" }; + static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10" }; + static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10" }; private static final ICommandEditor COMMAND_EDITOR; diff --git a/testing/newsrc/org/aspectj/testing/AjcTest.java b/testing/newsrc/org/aspectj/testing/AjcTest.java index 2cc450636..d56bc6e37 100644 --- a/testing/newsrc/org/aspectj/testing/AjcTest.java +++ b/testing/newsrc/org/aspectj/testing/AjcTest.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2004,2013 IBM Corporation, contributors + * Copyright (c) 2004,2018 IBM Corporation, contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 @@ -27,6 +27,7 @@ public class AjcTest { private static boolean is17VMOrGreater = false; private static boolean is18VMOrGreater = false; private static boolean is19VMOrGreater = false; + private static boolean is10VMOrGreater = false; static { // matching logic is also in org.aspectj.util.LangUtil is14VMOrGreater = LangUtil.is14VMOrGreater(); @@ -35,6 +36,7 @@ public class AjcTest { is17VMOrGreater = LangUtil.is17VMOrGreater(); is18VMOrGreater = LangUtil.is18VMOrGreater(); is19VMOrGreater = LangUtil.is19VMOrGreater(); + is10VMOrGreater = LangUtil.is10VMOrGreater(); } private List<ITestStep> testSteps = new ArrayList<ITestStep>(); @@ -78,6 +80,7 @@ public class AjcTest { if (vmLevel.equals("1.7")) canRun = is17VMOrGreater; if (vmLevel.equals("1.8")) canRun = is18VMOrGreater; if (vmLevel.equals("1.9")) canRun = is19VMOrGreater; + if (vmLevel.equals("10")) canRun = is10VMOrGreater; if (!canRun) { System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel() + ", currently running on " + System.getProperty("java.vm.version")); diff --git a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java new file mode 100644 index 000000000..492106d4d --- /dev/null +++ b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava10OrLater.java @@ -0,0 +1,31 @@ +/* ******************************************************************* + * Copyright (c) 2018 Contributors + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement + * ******************************************************************/ +package org.aspectj.testing; + +/** + * Makes sure tests are running on the right level of JDK. + * + * @author Andy Clement + */ +public abstract class XMLBasedAjcTestCaseForJava10OrLater extends XMLBasedAjcTestCase { + + @Override + public void runTest(String title) { + // Check we are on Java10 + String property = System.getProperty("java.version"); + if (!property.startsWith("10")) { + throw new IllegalStateException("These tests should be run on Java 10 or later"); + } + super.runTest(title); + } + +} diff --git a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java index 826cf55d3..205b55273 100644 --- a/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java +++ b/testing/newsrc/org/aspectj/testing/XMLBasedAjcTestCaseForJava9OrLater.java @@ -11,6 +11,8 @@ * ******************************************************************/ package org.aspectj.testing; +import org.aspectj.util.LangUtil; + /** * Makes sure tests are running on the right level of JDK. * @@ -20,9 +22,8 @@ public abstract class XMLBasedAjcTestCaseForJava9OrLater extends XMLBasedAjcTest @Override public void runTest(String title) { - // Check we are on Java9 - String property = System.getProperty("java.version"); - if (!property.startsWith("9")) { + // Check we are on Java9 or later + if (!LangUtil.is19VMOrGreater()) { throw new IllegalStateException("These tests should be run on Java 9 or later"); } super.runTest(title); diff --git a/tests/bugs191/var/Code1.java b/tests/bugs191/var/Code1.java new file mode 100644 index 000000000..58f93d1ba --- /dev/null +++ b/tests/bugs191/var/Code1.java @@ -0,0 +1,6 @@ +public class Code1 { + public static void main(String []argv) { + var x = "hello"; + System.out.println(x.getClass()); + } +} diff --git a/tests/bugs191/var/Code2.java b/tests/bugs191/var/Code2.java new file mode 100644 index 000000000..7f8ba93b6 --- /dev/null +++ b/tests/bugs191/var/Code2.java @@ -0,0 +1,11 @@ +import java.util.*; +public class Code2 { + public static void main(String []argv) { + foo(new ArrayList<String>()); + } + + public static void foo(ArrayList<String> als) { + var aly = als; + System.out.println(aly.getClass()); + } +} diff --git a/tests/bugs191/var/Code3.java b/tests/bugs191/var/Code3.java new file mode 100644 index 000000000..f2494bc6d --- /dev/null +++ b/tests/bugs191/var/Code3.java @@ -0,0 +1,12 @@ +public class Code3 { + public static void main(String []argv) { + var x = "hello"; + System.out.println(x.getClass()); + } +} + +aspect X { + before(): call(* *.getClass()) && target(String) { + System.out.println(thisJoinPointStaticPart); + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java index 58de6b447..866fbb729 100644 --- a/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java @@ -15,9 +15,6 @@ import java.io.PrintWriter; import java.util.Iterator; import java.util.List; -import junit.framework.Test; - -import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.LocalVariable; import org.aspectj.apache.bcel.classfile.LocalVariableTable; import org.aspectj.apache.bcel.classfile.Method; @@ -27,6 +24,8 @@ import org.aspectj.asm.IProgramElement; import org.aspectj.asm.IRelationship; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testGenericAspectsNpe_pr268689() { @@ -116,14 +115,14 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // assertEquals("/binaries<{Aspect.java}Aspect)Fruit.Fruit_new)QColor;)QString;", itdCtorHandle); assertEquals("/binaries<(Aspect.class'Aspect)Fruit.Fruit_new)QColor;)QString;", itdCtorHandle); IProgramElement itdcpe = model.getHierarchy().findElementForHandle(itdCtorHandle); - List ptypes = itdcpe.getParameterTypes(); - assertEquals("java.awt.Color", new String((char[]) ptypes.get(0))); - assertEquals("java.lang.String", new String((char[]) ptypes.get(1))); + List<char[]> ptypes = itdcpe.getParameterTypes(); + assertEquals("java.awt.Color", new String(ptypes.get(0))); + assertEquals("java.lang.String", new String(ptypes.get(1))); } private void printModel(AsmManager model) { try { - model.dumptree(model.getHierarchy().getRoot(), 0); + AsmManager.dumptree(model.getHierarchy().getRoot(), 0); model.dumprels(new PrintWriter(System.out)); } catch (Exception e) { } @@ -416,6 +415,7 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase { return XMLBasedAjcTestCase.loadSuite(Ajc164Tests.class); } + @Override protected File getSpecFile() { return getClassResource("ajc164.xml"); } @@ -427,9 +427,9 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase { if (whereToLook.getSourceLocation() != null && whereToLook.getSourceLocation().getLine() == line) { return whereToLook; } - List kids = whereToLook.getChildren(); - for (Iterator iterator = kids.iterator(); iterator.hasNext();) { - IProgramElement object = (IProgramElement) iterator.next(); + List<IProgramElement> kids = whereToLook.getChildren(); + for (Iterator<IProgramElement> iterator = kids.iterator(); iterator.hasNext();) { + IProgramElement object = iterator.next(); if (object.getSourceLocation() != null && object.getSourceLocation().getLine() == line) { return object; } diff --git a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java index 441e0b4e6..196e07ca1 100644 --- a/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc165/Ajc165Tests.java @@ -13,11 +13,12 @@ package org.aspectj.systemtest.ajc165; import java.io.File; import java.util.List; -import junit.framework.Test; - +import org.aspectj.bridge.IMessage; import org.aspectj.testing.XMLBasedAjcTestCase; import org.aspectj.weaver.LintMessage; +import junit.framework.Test; + public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { // fix is too disruptive for 1.6.5 @@ -82,7 +83,7 @@ public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testAnnotationStyle_pr265356() { runTest("annotation style message positions"); - List ms = ajc.getLastCompilationResult().getWarningMessages(); + List<IMessage> ms = ajc.getLastCompilationResult().getWarningMessages(); boolean checked = true; // Look for the message relating to 'List' and check the offsets for (int i = 0; i < ms.size(); i++) { @@ -115,6 +116,7 @@ public class Ajc165Tests extends org.aspectj.testing.XMLBasedAjcTestCase { return XMLBasedAjcTestCase.loadSuite(Ajc165Tests.class); } + @Override protected File getSpecFile() { return getClassResource("ajc165.xml"); } diff --git a/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java b/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java index 79d1a4669..6a713e930 100644 --- a/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java +++ b/tests/src/org/aspectj/systemtest/ajc171/NewFeatures.java @@ -12,11 +12,11 @@ package org.aspectj.systemtest.ajc171; import java.io.File; -import junit.framework.Test; - import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.testing.XMLBasedAjcTestCase; +import junit.framework.Test; + // NOTE THIS IS ACTUALLY IN 1.7.2 - IT IS JUST THAT THE PATCH WAS CREATED AGAINST 1.7.1 public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { @@ -60,10 +60,12 @@ public class NewFeatures extends org.aspectj.testing.XMLBasedAjcTestCase { return XMLBasedAjcTestCase.loadSuite(NewFeatures.class); } + @SuppressWarnings("unused") private JavaClass getMyClass(String className) throws ClassNotFoundException { return getClassFrom(ajc.getSandboxDirectory(), className); } + @Override protected File getSpecFile() { return new File("../tests/src/org/aspectj/systemtest/ajc171/newfeatures-tests.xml"); } diff --git a/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java b/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java new file mode 100644 index 000000000..230a9128d --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc191/Ajc191Tests.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc191; + +import java.io.File; + +import org.aspectj.testing.XMLBasedAjcTestCase; +import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater; + +import junit.framework.Test; + +/** + * @author Andy Clement + */ +public class Ajc191Tests extends XMLBasedAjcTestCaseForJava10OrLater { + + public void testVar1() { + runTest("var 1"); + } + + public void testVar2() { + runTest("var 2"); + } + + public void testVarIncludesAspect3() { + runTest("var 3"); + } + + // --- + + public static Test suite() { + return XMLBasedAjcTestCase.loadSuite(Ajc191Tests.class); + } + + @Override + protected File getSpecFile() { + return getClassResource("ajc191.xml"); + } + +} diff --git a/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java b/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java new file mode 100644 index 000000000..a42ad5b4c --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc191/AllTestsAspectJ191.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * Copyright (c) 2018 Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc191; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTestsAspectJ191 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ 1.9.1 tests"); + // $JUnit-BEGIN$ + suite.addTest(Ajc191Tests.suite()); + // $JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml b/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml new file mode 100644 index 000000000..ab14b9e73 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc191/ajc191.xml @@ -0,0 +1,36 @@ +<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> + +<suite> + + <ajc-test dir="bugs191/var" title="var 1"> + <compile files="Code1.java" options="-10"> + </compile> + <run class="Code1"> + <stdout> + <line text="class java.lang.String"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs191/var" title="var 2"> + <compile files="Code2.java" options="-10"> + </compile> + <run class="Code2"> + <stdout> + <line text="class java.util.ArrayList"/> + </stdout> + </run> + </ajc-test> + + <ajc-test dir="bugs191/var" title="var 3"> + <compile files="Code3.java" options="-10"> + </compile> + <run class="Code3"> + <stdout> + <line text="call(Class java.lang.Object.getClass())"/> + <line text="class java.util.ArrayList"/> + </stdout> + </run> + </ajc-test> + +</suite> diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java index c5e53cdeb..428c037d8 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/IncrementalPerformanceTests.java @@ -141,6 +141,7 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental // --- helper code --- + @SuppressWarnings("unused") private void waitFor10() { try { Thread.sleep(10000); @@ -149,6 +150,7 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental } } + @SuppressWarnings("unused") private void waitForReturn() { try { System.in.read(); @@ -157,11 +159,13 @@ public class IncrementalPerformanceTests extends AbstractMultiProjectIncremental } } + @Override protected void setUp() throws Exception { super.setUp(); testdataSrcDir = "../tests/incrementalPerformance"; } + @Override protected void tearDown() throws Exception { super.tearDown(); testdataSrcDir = "../tests/multiIncremental"; diff --git a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java index 308ed42d5..c35b88610 100644 --- a/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java +++ b/tests/src/org/aspectj/systemtest/incremental/tools/MoreOutputLocationManagerTests.java @@ -48,6 +48,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen private String inpathTestingDir; private String expectedOutputDir; + @Override protected void setUp() throws Exception { super.setUp(); initialiseProject("inpathTesting"); @@ -71,7 +72,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen Map.Entry<String,File> entry = iterator.next(); String className = entry.getKey(); String fullClassName = expectedOutputDir + File.separator + className.replace('.', File.separatorChar) + ".class"; - File file = (File) entry.getValue(); + File file = entry.getValue(); assertEquals("expected file to have path \n" + fullClassName + ", but" + " found path \n" + file.getAbsolutePath(), fullClassName, file.getAbsolutePath()); } @@ -289,7 +290,7 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen configureNonStandardCompileOptions("inpathTesting", "-outxml"); build("inpathTesting"); AjState state = getState(); - Map m = state.getAspectNamesToFileNameMap(); + Map<String,char[]> m = state.getAspectNamesToFileNameMap(); assertEquals("Expected only one aspect recored in the state but found " + m.size(), 1, m.size()); build("inpathTesting"); m = state.getAspectNamesToFileNameMap(); @@ -333,37 +334,46 @@ public class MoreOutputLocationManagerTests extends AbstractMultiProjectIncremen allOutputLocations.add(outputLoc); } + @Override public File getOutputLocationForClass(File compilationUnit) { return outputLoc; } + @Override public Map<File,String> getInpathMap() { return Collections.emptyMap(); } + @Override public File getOutputLocationForResource(File resource) { return outputLoc; } + @Override public List<File> getAllOutputLocations() { return allOutputLocations; } + @Override public File getDefaultOutputLocation() { return outputLoc; } + @Override public void reportFileWrite(String outputfile, int filetype) { } + @Override public void reportFileRemove(String outputfile, int filetype) { } + @Override public String getSourceFolderForFile(File sourceFile) { return null; // no impl } + @Override public int discoverChangesSince(File dir, long buildtime) { return 0; // no impl } diff --git a/util/src/org/aspectj/util/LangUtil.java b/util/src/org/aspectj/util/LangUtil.java index ff6c7246c..ad83a4edd 100644 --- a/util/src/org/aspectj/util/LangUtil.java +++ b/util/src/org/aspectj/util/LangUtil.java @@ -1,6 +1,7 @@ /* ******************************************************************* * Copyright (c) 1999-2001 Xerox Corporation, * 2002 Palo Alto Research Center, Incorporated (PARC). + * 2018 Contributors * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 @@ -151,6 +152,10 @@ public class LangUtil { public static boolean is19VMOrGreater() { return 9 <= vmVersion; } + + public static boolean is10VMOrGreater() { + return 10 <= vmVersion; + } /** * Shorthand for "if null, throw IllegalArgumentException" @@ -267,7 +272,7 @@ public class LangUtil { * @param text <code>String</code> to split. */ public static String[] split(String text) { - return (String[]) strings(text).toArray(new String[0]); + return strings(text).toArray(new String[0]); } /** @@ -298,7 +303,7 @@ public class LangUtil { result.add(entry); } } - return (String[]) result.toArray(new String[0]); + return result.toArray(new String[0]); } /** @@ -886,7 +891,7 @@ public class LangUtil { String line; int elided = 0; while (!lines.isEmpty()) { - line = (String) lines.getLast(); + line = lines.getLast(); if (!checker.acceptString(line)) { break; } else { @@ -898,7 +903,7 @@ public class LangUtil { final int EOL_LEN = EOL.length(); int totalLength = 0; while (!lines.isEmpty()) { - totalLength += EOL_LEN + ((String) lines.getFirst()).length(); + totalLength += EOL_LEN + lines.getFirst().length(); lines.removeFirst(); } if (stack.length() > totalLength) { @@ -1060,7 +1065,7 @@ public class LangUtil { if (!LangUtil.isEmpty(args)) { cmd.addAll(Arrays.asList(args)); } - String[] command = (String[]) cmd.toArray(new String[0]); + String[] command = cmd.toArray(new String[0]); if (null == controller) { controller = new ProcessController(); } @@ -1249,7 +1254,7 @@ public class LangUtil { if (!LangUtil.isEmpty(args)) { cmd.addAll(Arrays.asList(args)); } - init((String[]) cmd.toArray(new String[0]), mainClass); + init(cmd.toArray(new String[0]), mainClass); } public final void init(String[] command, String label) { @@ -1315,6 +1320,7 @@ public class LangUtil { inStream = new FileUtil.Pipe(System.in, process.getOutputStream()); // start 4 threads, process & pipes for in, err, out Runnable processRunner = new Runnable() { + @Override public void run() { Throwable thrown = null; int result = Integer.MIN_VALUE; @@ -1466,6 +1472,7 @@ public class LangUtil { thrown = ((null != fromProcess) || (null != fromInPipe) || (null != fromOutPipe) || (null != fromErrPipe)); } + @Override public String toString() { StringBuffer sb = new StringBuffer(); append(sb, fromProcess, "process"); diff --git a/weaver/.classpath b/weaver/.classpath index 995d885a7..dd355f8e5 100644 --- a/weaver/.classpath +++ b/weaver/.classpath @@ -13,6 +13,6 @@ <classpathentry kind="lib" path="/lib/bcel/bcel.jar" sourcepath="/lib/bcel/bcel-src.zip"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> <classpathentry combineaccessrules="false" kind="src" path="/org.aspectj.matcher"/> - <classpathentry kind="lib" path="/lib/asm/asm-6.0.renamed.jar"/> + <classpathentry kind="lib" path="/lib/asm/asm-6.1.1.renamed.jar"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java index f6f3ab40e..d39299ace 100644 --- a/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java @@ -118,12 +118,8 @@ public abstract class WeaveTestCase extends TestCase { gen = classType.getLazyClassGen(); // new LazyClassGen(classType); } try { - File possibleVmSpecificFile = new File(TESTDATA_DIR,outName + "." + LangUtil.getVmVersionString()+".txt"); - if (possibleVmSpecificFile.exists()) { - checkClass(gen, outDirPath, outName + "." + LangUtil.getVmVersionString()+".txt"); - } else { - checkClass(gen, outDirPath, outName + ".txt"); - } + String filenameToUse = findMostRelevantFile(outName); + checkClass(gen, outDirPath, filenameToUse); if (runTests) { System.out.println("*******RUNNING: " + outName + " " + name + " *******"); TestUtil.runMain(makeClassPath(outDirPath), name); @@ -137,6 +133,19 @@ public abstract class WeaveTestCase extends TestCase { throw e; } } + + public String findMostRelevantFile(String name) { + double version = LangUtil.getVmVersion(); + while (version > 0) { + String possibleFileName = name+"."+Double.toString(version)+".txt"; + if (new File(TESTDATA_DIR, possibleFileName).exists()) { + return possibleFileName; + } + version--; + } + // Use the standard file + return name+".txt"; + } public String makeClassPath(String outDir) { return outDir + File.pathSeparator + getTraceJar() + File.pathSeparator + classDir + File.pathSeparator |