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
// }
// } );
- // 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;
// 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();
+ }
}
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
}
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
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();
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)
}
// 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);
}
/**
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 {
return;
}
files = FileUtil.listFiles(rootDir, new FileFilter() {
+ @Override
public boolean accept(File f) {
return f.getName().equals("package-summary.html");
}
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);
}
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: " +
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) {
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;
}
// 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();
}
});
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
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
protected static File sandboxDir;
private String docOutdir, projectDir;
+ @Override
protected void setUp() throws Exception {
super.setUp();
docOutdir = null;
Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
// reset where ajdocworkingdir is created
!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];
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;
*/
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
*
* @deprecated Use SYSTEM_CLASS_PATH constant
*/
+ @Deprecated
public ClassPath() {
this(getClassPath());
}
/**
* @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);
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");
}
// 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);
}
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();
}
+ @Override
public long getTime() {
return file.lastModified();
}
+ @Override
public long getSize() {
return file.length();
}
+ @Override
public String getBase() {
return dir;
}
} : null;
}
+ @Override
public String toString() {
return dir;
}
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)
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();
}
<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>
} 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");
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;
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;
*/
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;
}
}
+ @Override
protected char[] getPrefix() {
return (NameMangler.ITD_PREFIX + "interMethod$").toCharArray();
}
super.analyseCode(classScope, flowContext, flowInfo);
}
+ @Override
public void resolve(ClassScope upperScope) {
if (munger == null)
ignoreFurtherInvestigation = true;
super.resolve(upperScope);
}
+ @Override
public void resolveStatements() {
checkAndSetModifiersForMethod();
if ((modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) {
}
}
+ @Override
public EclipseTypeMunger build(ClassScope classScope) {
EclipseFactory factory = EclipseFactory.fromScopeLookupEnvironment(classScope);
return new AjAttribute.TypeMunger(munger);
}
+ @Override
public void generateCode(ClassScope classScope, ClassFile classFile) {
if (ignoreFurtherInvestigation) {
// System.err.println("no code for " + this);
classFile.completeMethodInfo(binding,methodAttributeOffset, attributeNumber);
}
+ @Override
protected Shadow.Kind getShadowKindForBody() {
return Shadow.MethodExecution;
}
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()),
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;
+ 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:
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;
/* *******************************************************************
- * 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
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();
is17VMOrGreater = LangUtil.is17VMOrGreater();
is18VMOrGreater = LangUtil.is18VMOrGreater();
is19VMOrGreater = LangUtil.is19VMOrGreater();
+ is10VMOrGreater = LangUtil.is10VMOrGreater();
}
private List<ITestStep> testSteps = new ArrayList<ITestStep>();
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"));
--- /dev/null
+/* *******************************************************************
+ * 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);
+ }
+
+}
* ******************************************************************/
package org.aspectj.testing;
+import org.aspectj.util.LangUtil;
+
/**
* Makes sure tests are running on the right level of JDK.
*
@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);
--- /dev/null
+public class Code1 {
+ public static void main(String []argv) {
+ var x = "hello";
+ System.out.println(x.getClass());
+ }
+}
--- /dev/null
+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());
+ }
+}
--- /dev/null
+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);
+ }
+}
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;
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() {
// 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) {
}
return XMLBasedAjcTestCase.loadSuite(Ajc164Tests.class);
}
+ @Override
protected File getSpecFile() {
return getClassResource("ajc164.xml");
}
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;
}
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
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++) {
return XMLBasedAjcTestCase.loadSuite(Ajc165Tests.class);
}
+ @Override
protected File getSpecFile() {
return getClassResource("ajc165.xml");
}
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 {
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");
}
--- /dev/null
+/*******************************************************************************
+ * 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");
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * 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;
+ }
+}
--- /dev/null
+<!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>
// --- helper code ---
+ @SuppressWarnings("unused")
private void waitFor10() {
try {
Thread.sleep(10000);
}
}
+ @SuppressWarnings("unused")
private void waitForReturn() {
try {
System.in.read();
}
}
+ @Override
protected void setUp() throws Exception {
super.setUp();
testdataSrcDir = "../tests/incrementalPerformance";
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
testdataSrcDir = "../tests/multiIncremental";
private String inpathTestingDir;
private String expectedOutputDir;
+ @Override
protected void setUp() throws Exception {
super.setUp();
initialiseProject("inpathTesting");
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());
}
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();
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
}
/* *******************************************************************
* 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
public static boolean is19VMOrGreater() {
return 9 <= vmVersion;
}
+
+ public static boolean is10VMOrGreater() {
+ return 10 <= vmVersion;
+ }
/**
* Shorthand for "if null, throw IllegalArgumentException"
* @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]);
}
/**
result.add(entry);
}
}
- return (String[]) result.toArray(new String[0]);
+ return result.toArray(new String[0]);
}
/**
String line;
int elided = 0;
while (!lines.isEmpty()) {
- line = (String) lines.getLast();
+ line = lines.getLast();
if (!checker.acceptString(line)) {
break;
} else {
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) {
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();
}
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) {
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;
thrown = ((null != fromProcess) || (null != fromInPipe) || (null != fromOutPipe) || (null != fromErrPipe));
}
+ @Override
public String toString() {
StringBuffer sb = new StringBuffer();
append(sb, fromProcess, "process");
<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>
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);
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