private Set aspectpath; | private Set aspectpath; | ||||
private Set inpath; | private Set inpath; | ||||
private String outjar; | private String outjar; | ||||
private Map javaOptions; | |||||
private Map<String,String> javaOptions; | |||||
private String nonStandardOptions; | private String nonStandardOptions; | ||||
private List projectSourceFiles = new ArrayList(); | private List projectSourceFiles = new ArrayList(); | ||||
private Map sourcePathResources; | private Map sourcePathResources; | ||||
return inpath; | return inpath; | ||||
} | } | ||||
public Map getJavaOptionsMap() { | |||||
public Map<String,String> getJavaOptionsMap() { | |||||
if (javaOptions == null) { | if (javaOptions == null) { | ||||
javaOptions = new Hashtable(); | |||||
javaOptions = new Hashtable<>(); | |||||
javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); | javaOptions.put(JavaOptions.COMPLIANCE_LEVEL, JavaOptions.VERSION_13); | ||||
javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); | javaOptions.put(JavaOptions.SOURCE_COMPATIBILITY_LEVEL, JavaOptions.VERSION_13); | ||||
} | } | ||||
} | } | ||||
public String getProcessor() { | public String getProcessor() { | ||||
// TODO Auto-generated method stub | |||||
return null; | return null; | ||||
} | } | ||||
public String getProcessorPath() { | public String getProcessorPath() { | ||||
// TODO Auto-generated method stub | |||||
return null; | return null; | ||||
} | } | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import org.aspectj.util.LangUtil; | |||||
/** | /** | ||||
* Helper class to check whether the ajdoc contains the expected | * Helper class to check whether the ajdoc contains the expected | ||||
* information. | * information. | ||||
// found the required main section | // found the required main section | ||||
String nextLine = reader.readLine(); | String nextLine = reader.readLine(); | ||||
while (nextLine != null && (nextLine.indexOf("========") == -1)) { | while (nextLine != null && (nextLine.indexOf("========") == -1)) { | ||||
if (nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) { | |||||
// On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit"> | |||||
if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) || | |||||
nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) { | |||||
// found the required subsection | // found the required subsection | ||||
String subLine = reader.readLine(); | String subLine = reader.readLine(); | ||||
while(subLine != null | while(subLine != null | ||||
reader.close(); | reader.close(); | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
* Returns whether the supplied source has the expected | * Returns whether the supplied source has the expected | ||||
* relationship and target within the given summary section | * relationship and target within the given summary section |
} | } | ||||
String[] strings = { | String[] strings = { | ||||
toName("Point()"), | |||||
LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), | |||||
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""}; | "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""}; | ||||
boolean b = AjdocOutputChecker.detailSectionContainsRel( | boolean b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR DETAIL", | htmlFile,"=== CONSTRUCTOR DETAIL", | ||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
strings[1]); | strings[1]); | ||||
assertTrue("the Constructor Detail should have " + strings[0]+" advised by " + strings[1],b); | assertTrue("the Constructor Detail should have " + strings[0]+" advised by " + strings[1],b); | ||||
// Pre-JDK 11: | |||||
// This precedes the line containing strings[1] | |||||
// <td class="colOne"><code><span class="memberNameLink"><a href="../foo/Point.html#Point--">Point</a></span>()</code> | |||||
// On JDK 11: | |||||
// This precedes the line containing strings[1] | |||||
// <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Point</a></span>()</code></th> | |||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR SUMMARY", | htmlFile,"=== CONSTRUCTOR SUMMARY", | ||||
strings[0], | |||||
LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"), | |||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
strings[1]); | strings[1]); | ||||
assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b); | assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b); | ||||
b = AjdocOutputChecker.detailSectionContainsRel( | b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR DETAIL", | htmlFile,"=== CONSTRUCTOR DETAIL", | ||||
toName("Point()"), | |||||
LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), | |||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
href); | href); | ||||
assertTrue("the Constructor Detail should have advised by " + href,b); | assertTrue("the Constructor Detail should have advised by " + href,b); | ||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR SUMMARY", | htmlFile,"=== CONSTRUCTOR SUMMARY", | ||||
toName("Point()"), | |||||
LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"), | |||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
href); | href); | ||||
assertTrue("the Constructor Summary should have advised by " + href,b); | assertTrue("the Constructor Summary should have advised by " + href,b); | ||||
} | } | ||||
String[] strings = { | String[] strings = { | ||||
toName("Point()"), | |||||
LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), | |||||
"HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""}; | "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""}; | ||||
boolean b = AjdocOutputChecker.detailSectionContainsRel( | boolean b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR DETAIL",strings[0], | |||||
htmlFile, | |||||
"=== CONSTRUCTOR DETAIL", | |||||
strings[0], | |||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
strings[1]); | strings[1]); | ||||
assertTrue("the Method Detail should have 'setX(int) advised by ... before()'",b); | assertTrue("the Method Detail should have 'setX(int) advised by ... before()'",b); | ||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR SUMMARY",strings[0], | |||||
htmlFile, | |||||
"=== CONSTRUCTOR SUMMARY", | |||||
LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":strings[0], | |||||
HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, | ||||
strings[1]); | strings[1]); | ||||
assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b); | assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b); | ||||
} | } | ||||
private String toName(String name) { | private String toName(String name) { | ||||
if (LangUtil.is18VMOrGreater()) { | |||||
if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) { | |||||
name = name.replace('(','-'); | name = name.replace('(','-'); | ||||
name = name.replace(')','-'); | name = name.replace(')','-'); | ||||
} | } |
boolean b = AjdocOutputChecker.detailSectionContainsRel( | boolean b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== METHOD DETAIL", | htmlFile,"=== METHOD DETAIL", | ||||
LangUtil.is18VMOrGreater()?"doIt--":doIt, | |||||
// doIt, | |||||
toName(doIt), | |||||
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | ||||
declareWarningQuotes); | declareWarningQuotes); | ||||
assertTrue("Should have '" + doIt + " matches declare " + | assertTrue("Should have '" + doIt + " matches declare " + | ||||
declareWarningQuotes + "' in the Declare Detail section", b); | declareWarningQuotes + "' in the Declare Detail section", b); | ||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== METHOD SUMMARY", | htmlFile,"=== METHOD SUMMARY", | ||||
LangUtil.is18VMOrGreater()?"doIt--":doIt, | |||||
toName(doIt), | |||||
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | ||||
declareWarningQuotes); | declareWarningQuotes); | ||||
assertTrue("Should have '" + doIt + " matches declare " + | assertTrue("Should have '" + doIt + " matches declare " + | ||||
boolean b = AjdocOutputChecker.detailSectionContainsRel( | boolean b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== METHOD DETAIL", | htmlFile,"=== METHOD DETAIL", | ||||
LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", | |||||
toName("setX(int)"), | |||||
// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", | |||||
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | ||||
"declare warning: quot;blahquot;"); | "declare warning: quot;blahquot;"); | ||||
assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + | assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + | ||||
"' in the Method Detail section", b); | "' in the Method Detail section", b); | ||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== METHOD SUMMARY", | htmlFile,"=== METHOD SUMMARY", | ||||
LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", | |||||
toName("setX(int)"), | |||||
// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", | |||||
HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, | ||||
"declare warning: quot;blahquot;"); | "declare warning: quot;blahquot;"); | ||||
assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + | assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + | ||||
} | } | ||||
private String toName(String name) { | private String toName(String name) { | ||||
if (LangUtil.is18VMOrGreater()) { | |||||
if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) { | |||||
name = name.replace('(','-'); | name = name.replace('(','-'); | ||||
name = name.replace(')','-'); | name = name.replace(')','-'); | ||||
} | } | ||||
boolean b = AjdocOutputChecker.detailSectionContainsRel( | boolean b = AjdocOutputChecker.detailSectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR DETAIL", | htmlFile,"=== CONSTRUCTOR DETAIL", | ||||
toName("C(java.lang.String)"), | |||||
LangUtil.is11VMOrGreater()?"<init>(java.lang.String)":toName("C(java.lang.String)"), | |||||
HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, | HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, | ||||
"declare @constructor: foo.C.new(..) : @MyAnnotation"); | "declare @constructor: foo.C.new(..) : @MyAnnotation"); | ||||
assertTrue("Should have '" + doIt + " annotated by " + | assertTrue("Should have '" + doIt + " annotated by " + | ||||
"' in the Method Detail section", b); | "' in the Method Detail section", b); | ||||
b = AjdocOutputChecker.summarySectionContainsRel( | b = AjdocOutputChecker.summarySectionContainsRel( | ||||
htmlFile,"=== CONSTRUCTOR SUMMARY", | htmlFile,"=== CONSTRUCTOR SUMMARY", | ||||
toName("C(java.lang.String)"), | |||||
LangUtil.is11VMOrGreater()?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"), | |||||
HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, | HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, | ||||
"declare @constructor: foo.C.new(..) : @MyAnnotation"); | "declare @constructor: foo.C.new(..) : @MyAnnotation"); | ||||
assertTrue("Should have '" + doIt + " annotated by " + | assertTrue("Should have '" + doIt + " annotated by " + |
public final static short MINOR_1_9 = 0; | public final static short MINOR_1_9 = 0; | ||||
public final static short MAJOR_10 = 54; | public final static short MAJOR_10 = 54; | ||||
public final static short MINOR_10 = 0; | public final static short MINOR_10 = 0; | ||||
public final static short MAJOR_11 = 55; | |||||
public final static short MINOR_11 = 0; | |||||
// Defaults | // Defaults | ||||
public final static short MAJOR = MAJOR_1_1; | public final static short MAJOR = MAJOR_1_1; | ||||
public final static short MINOR = MINOR_1_1; | public final static short MINOR = MINOR_1_1; | ||||
public final static byte CONSTANT_MethodHandle = 15; | public final static byte CONSTANT_MethodHandle = 15; | ||||
public final static byte CONSTANT_MethodType = 16; | public final static byte CONSTANT_MethodType = 16; | ||||
public final static byte CONSTANT_Dynamic = 17; | |||||
public final static byte CONSTANT_InvokeDynamic = 18; | public final static byte CONSTANT_InvokeDynamic = 18; | ||||
// J9: | |||||
public final static byte CONSTANT_Module = 19; | public final static byte CONSTANT_Module = 19; | ||||
public final static byte CONSTANT_Package = 20; | public final static byte CONSTANT_Package = 20; | ||||
public void visitConstantMethodType(ConstantMethodType obj); | public void visitConstantMethodType(ConstantMethodType obj); | ||||
public void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); | public void visitConstantInvokeDynamic(ConstantInvokeDynamic obj); | ||||
public void visitConstantDynamic(ConstantDynamic obj); | |||||
public void visitConstantPool(ConstantPool obj); | public void visitConstantPool(ConstantPool obj); | ||||
return new ConstantMethodType(dis); | return new ConstantMethodType(dis); | ||||
case Constants.CONSTANT_InvokeDynamic: | case Constants.CONSTANT_InvokeDynamic: | ||||
return new ConstantInvokeDynamic(dis); | return new ConstantInvokeDynamic(dis); | ||||
case Constants.CONSTANT_Module: return new ConstantModule(dis); | |||||
case Constants.CONSTANT_Package: return new ConstantPackage(dis); | |||||
case Constants.CONSTANT_Module: | |||||
return new ConstantModule(dis); | |||||
case Constants.CONSTANT_Package: | |||||
return new ConstantPackage(dis); | |||||
case Constants.CONSTANT_Dynamic: | |||||
return new ConstantDynamic(dis); | |||||
default: | default: | ||||
throw new ClassFormatException("Invalid byte tag in constant pool: " + b); | throw new ClassFormatException("Invalid byte tag in constant pool: " + b); | ||||
} | } |
/* ==================================================================== | |||||
* The Apache Software License, Version 1.1 | |||||
* | |||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* reserved. | |||||
* | |||||
* Redistribution and use in source and binary forms, with or without | |||||
* modification, are permitted provided that the following conditions | |||||
* are met: | |||||
* | |||||
* 1. Redistributions of source code must retain the above copyright | |||||
* notice, this list of conditions and the following disclaimer. | |||||
* | |||||
* 2. Redistributions in binary form must reproduce the above copyright | |||||
* notice, this list of conditions and the following disclaimer in | |||||
* the documentation and/or other materials provided with the | |||||
* distribution. | |||||
* | |||||
* 3. The end-user documentation included with the redistribution, | |||||
* if any, must include the following acknowledgment: | |||||
* "This product includes software developed by the | |||||
* Apache Software Foundation (http://www.apache.org/)." | |||||
* Alternately, this acknowledgment may appear in the software itself, | |||||
* if and wherever such third-party acknowledgments normally appear. | |||||
* | |||||
* 4. The names "Apache" and "Apache Software Foundation" and | |||||
* "Apache BCEL" must not be used to endorse or promote products | |||||
* derived from this software without prior written permission. For | |||||
* written permission, please contact apache@apache.org. | |||||
* | |||||
* 5. Products derived from this software may not be called "Apache", | |||||
* "Apache BCEL", nor may "Apache" appear in their name, without | |||||
* prior written permission of the Apache Software Foundation. | |||||
* | |||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||||
* SUCH DAMAGE. | |||||
* ==================================================================== | |||||
* | |||||
* This software consists of voluntary contributions made by many | |||||
* individuals on behalf of the Apache Software Foundation. For more | |||||
* information on the Apache Software Foundation, please see | |||||
* <http://www.apache.org/>. | |||||
*/ | |||||
package org.aspectj.apache.bcel.classfile; | |||||
import java.io.DataInputStream; | |||||
import java.io.DataOutputStream; | |||||
import java.io.IOException; | |||||
import org.aspectj.apache.bcel.Constants; | |||||
/** | |||||
* This class is derived from the abstract <A HREF="org.aspectj.apache.bcel.classfile.Constant.html">Constant</A> class and | |||||
* represents a reference to the name and signature of a field or method. | |||||
* | |||||
* http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4.10 | |||||
* | |||||
* @author Andy Clement | |||||
* @see Constant | |||||
*/ | |||||
public final class ConstantDynamic extends Constant { | |||||
private final int bootstrapMethodAttrIndex; | |||||
private final int nameAndTypeIndex; | |||||
ConstantDynamic(DataInputStream file) throws IOException { | |||||
this(file.readUnsignedShort(), file.readUnsignedShort()); | |||||
} | |||||
public ConstantDynamic(int readUnsignedShort, int nameAndTypeIndex) { | |||||
super(Constants.CONSTANT_InvokeDynamic); | |||||
this.bootstrapMethodAttrIndex = readUnsignedShort; | |||||
this.nameAndTypeIndex = nameAndTypeIndex; | |||||
} | |||||
@Override | |||||
public final void dump(DataOutputStream file) throws IOException { | |||||
file.writeByte(tag); | |||||
file.writeShort(bootstrapMethodAttrIndex); | |||||
file.writeShort(nameAndTypeIndex); | |||||
} | |||||
public final int getNameAndTypeIndex() { | |||||
return nameAndTypeIndex; | |||||
} | |||||
public final int getBootstrapMethodAttrIndex() { | |||||
return bootstrapMethodAttrIndex; | |||||
} | |||||
@Override | |||||
public final String toString() { | |||||
return super.toString() + "(bootstrapMethodAttrIndex=" + bootstrapMethodAttrIndex + ",nameAndTypeIndex=" + nameAndTypeIndex + ")"; | |||||
} | |||||
@Override | |||||
public String getValue() { | |||||
return toString(); | |||||
} | |||||
@Override | |||||
public void accept(ClassVisitor v) { | |||||
v.visitConstantDynamic(this); | |||||
} | |||||
} |
} | } | ||||
// On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem | // On Java9 the sun.boot.class.path won't be set. System classes accessible through JRT filesystem | ||||
if (vm_version.startsWith("9") || vm_version.startsWith("10")) { | |||||
if (vm_version.startsWith("9") || vm_version.startsWith("10") || vm_version.startsWith("11")) { | |||||
buf.insert(0, File.pathSeparatorChar); | buf.insert(0, File.pathSeparatorChar); | ||||
buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS); | buf.insert(0, System.getProperty("java.home") + File.separator + "lib" + File.separator + JRT_FS); | ||||
} | } |
import org.aspectj.apache.bcel.classfile.Constant; | import org.aspectj.apache.bcel.classfile.Constant; | ||||
import org.aspectj.apache.bcel.classfile.ConstantClass; | import org.aspectj.apache.bcel.classfile.ConstantClass; | ||||
import org.aspectj.apache.bcel.classfile.ConstantDouble; | import org.aspectj.apache.bcel.classfile.ConstantDouble; | ||||
import org.aspectj.apache.bcel.classfile.ConstantDynamic; | |||||
import org.aspectj.apache.bcel.classfile.ConstantFieldref; | import org.aspectj.apache.bcel.classfile.ConstantFieldref; | ||||
import org.aspectj.apache.bcel.classfile.ConstantFloat; | import org.aspectj.apache.bcel.classfile.ConstantFloat; | ||||
import org.aspectj.apache.bcel.classfile.ConstantInteger; | import org.aspectj.apache.bcel.classfile.ConstantInteger; | ||||
throw new IllegalStateException("nyi"); | throw new IllegalStateException("nyi"); | ||||
} | } | ||||
public void visitConstantDynamic(ConstantDynamic obj) { | |||||
throw new IllegalStateException("nyi"); | |||||
} | |||||
public void visitBootstrapMethods(BootstrapMethods obj) { | public void visitBootstrapMethods(BootstrapMethods obj) { | ||||
throw new IllegalStateException("nyi"); | throw new IllegalStateException("nyi"); | ||||
} | } |
import org.aspectj.apache.bcel.classfile.CodeException; | import org.aspectj.apache.bcel.classfile.CodeException; | ||||
import org.aspectj.apache.bcel.classfile.ConstantClass; | import org.aspectj.apache.bcel.classfile.ConstantClass; | ||||
import org.aspectj.apache.bcel.classfile.ConstantDouble; | import org.aspectj.apache.bcel.classfile.ConstantDouble; | ||||
import org.aspectj.apache.bcel.classfile.ConstantDynamic; | |||||
import org.aspectj.apache.bcel.classfile.ConstantFieldref; | import org.aspectj.apache.bcel.classfile.ConstantFieldref; | ||||
import org.aspectj.apache.bcel.classfile.ConstantFloat; | import org.aspectj.apache.bcel.classfile.ConstantFloat; | ||||
import org.aspectj.apache.bcel.classfile.ConstantInteger; | import org.aspectj.apache.bcel.classfile.ConstantInteger; | ||||
public void visitModule(Module attribute) {} | public void visitModule(Module attribute) {} | ||||
public void visitModulePackages(ModulePackages attribute) {} | public void visitModulePackages(ModulePackages attribute) {} | ||||
public void visitModuleMainClass(ModuleMainClass attribute) {} | public void visitModuleMainClass(ModuleMainClass attribute) {} | ||||
public void visitConstantDynamic(ConstantDynamic obj) {} | |||||
} | } |
import java.util.Locale; | import java.util.Locale; | ||||
import java.util.TimeZone; | import java.util.TimeZone; | ||||
import org.aspectj.util.LangUtil; | |||||
import junit.framework.TestCase; | import junit.framework.TestCase; | ||||
import junit.textui.TestRunner; | import junit.textui.TestRunner; | ||||
} | } | ||||
public void testVersion() { | public void testVersion() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
return; | |||||
} | |||||
if (Version.time_text.equals("")) { | if (Version.time_text.equals("")) { | ||||
return; // dev build, we can only test this on the build server. | return; // dev build, we can only test this on the build server. | ||||
} | } |
<!-- if you need this defining, use the jarjar-1.0.jar in this project --> | <!-- if you need this defining, use the jarjar-1.0.jar in this project --> | ||||
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"/> | <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.1.1.renamed.jar"> | |||||
<zipfileset src="asm-6.1.1.jar" excludes="module-info.class"/> | |||||
<target name="package" description="Jarjar asm-NNN.jar and prefix package name with aj"> | |||||
<jarjar destfile="asm-6.2.1.renamed.jar"> | |||||
<zipfileset src="asm-6.2.1.jar" excludes="module-info.class"/> | |||||
<rule pattern="org.objectweb.asm.**" result="aj.org.objectweb.asm.@1"/> | <rule pattern="org.objectweb.asm.**" result="aj.org.objectweb.asm.@1"/> | ||||
</jarjar> | </jarjar> | ||||
</target> | </target> |
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.lang.invoke.MethodHandle; | |||||
import java.lang.invoke.MethodHandles; | |||||
import java.lang.invoke.MethodHandles.Lookup; | |||||
import java.lang.invoke.MethodType; | |||||
import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||
import java.lang.reflect.Method; | |||||
import java.net.MalformedURLException; | import java.net.MalformedURLException; | ||||
import java.net.URL; | import java.net.URL; | ||||
import java.security.ProtectionDomain; | import java.security.ProtectionDomain; | ||||
return unsafe; | return unsafe; | ||||
} | } | ||||
private void defineClass(ClassLoader loader, String name, byte[] bytes) { | |||||
if (trace.isTraceEnabled()) { | |||||
trace.enter("defineClass", this, new Object[] { loader, name, bytes }); | |||||
} | |||||
Object clazz = null; | |||||
debug("generating class '" + name + "'"); | |||||
private static Method bindTo_Method, invokeWithArguments_Method = null; | |||||
private static Object defineClassMethodHandle = null; | |||||
private static Boolean initializedForJava11 = false; | |||||
// In order to let this code compile on earlier versions of Java (8), use reflection to discover the elements | |||||
// we need to define classes. | |||||
private static synchronized void initializeForJava11() { | |||||
if (initializedForJava11) return; | |||||
try { | try { | ||||
clazz = getUnsafe().defineClass(name, bytes, 0, bytes.length, loader, null); | |||||
} catch (LinkageError le) { | |||||
// likely thrown due to defining something that already exists? | |||||
// Old comments from before moving to Unsafe.defineClass(): | |||||
// is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved) | |||||
// TODO maw I don't think this is OK and | |||||
// MethodType defineClassMethodType = MethodType.methodType(Class.class, new Class[]{String.class, byte[].class, int.class, int.class}); | |||||
Class<?> methodType_Class = Class.forName("java.lang.invoke.MethodType"); | |||||
Method methodTypeMethodOnMethodTypeClass = methodType_Class.getDeclaredMethod("methodType", Class.class,Class[].class); | |||||
methodTypeMethodOnMethodTypeClass.setAccessible(true); | |||||
Object defineClassMethodType = methodTypeMethodOnMethodTypeClass.invoke(null, Class.class, new Class[] {String.class,byte[].class,int.class,int.class}); | |||||
// MethodHandles.Lookup methodHandlesLookup = MethodHandles.lookup(); | |||||
Class<?> methodHandles_Class = Class.forName("java.lang.invoke.MethodHandles"); | |||||
Method lookupMethodOnMethodHandlesClass = methodHandles_Class.getDeclaredMethod("lookup"); | |||||
lookupMethodOnMethodHandlesClass.setAccessible(true); | |||||
Object methodHandlesLookup = lookupMethodOnMethodHandlesClass.invoke(null); | |||||
// MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(ClassLoader.class, baseLookup); | |||||
Class<?> methodHandlesLookup_Class = Class.forName("java.lang.invoke.MethodHandles$Lookup"); | |||||
Method privateLookupMethodOnMethodHandlesClass = methodHandles_Class.getDeclaredMethod("privateLookupIn",Class.class,methodHandlesLookup_Class); | |||||
privateLookupMethodOnMethodHandlesClass.setAccessible(true); | |||||
Object lookup = privateLookupMethodOnMethodHandlesClass.invoke(null, ClassLoader.class, methodHandlesLookup); | |||||
// MethodHandle defineClassMethodHandle = lookup.findVirtual(ClassLoader.class, "defineClass", defineClassMethodType); | |||||
Method findVirtual_Method = methodHandlesLookup_Class.getDeclaredMethod("findVirtual", Class.class,String.class,methodType_Class); | |||||
findVirtual_Method.setAccessible(true); | |||||
defineClassMethodHandle = findVirtual_Method.invoke(lookup, ClassLoader.class, "defineClass",defineClassMethodType); | |||||
// clazz = defineClassMethodHandle.bindTo(loader).invokeWithArguments(name, bytes, 0, bytes.length); | |||||
Class<?> methodHandle_Class = Class.forName("java.lang.invoke.MethodHandle"); | |||||
bindTo_Method = methodHandle_Class.getDeclaredMethod("bindTo", Object.class); | |||||
invokeWithArguments_Method = methodHandle_Class.getDeclaredMethod("invokeWithArguments",Object[].class); | |||||
initializedForJava11 = true; | |||||
} catch (Exception e) { | } catch (Exception e) { | ||||
e.printStackTrace(System.err); | |||||
warn("define generated class failed", e); | |||||
} | |||||
if (trace.isTraceEnabled()) { | |||||
trace.exit("defineClass", clazz); | |||||
e.printStackTrace(); | |||||
} | } | ||||
} | } | ||||
private void defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain) { | private void defineClass(ClassLoader loader, String name, byte[] bytes, ProtectionDomain protectionDomain) { | ||||
if (trace.isTraceEnabled()) { | if (trace.isTraceEnabled()) { | ||||
trace.enter("defineClass", this, new Object[] { loader, name, bytes, protectionDomain }); | |||||
trace.enter("defineClass", this, new Object[] { loader, name, bytes }); | |||||
} | } | ||||
Object clazz = null; | Object clazz = null; | ||||
debug("generating class '" + name + "'"); | debug("generating class '" + name + "'"); | ||||
try { | |||||
getUnsafe().defineClass(name, bytes, 0, bytes.length, loader, protectionDomain); | |||||
} catch (LinkageError le) { | |||||
// likely thrown due to defining something that already exists? | |||||
// Old comments from before moving to Unsafe.defineClass(): | |||||
// is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved) | |||||
// TODO maw I don't think this is OK and | |||||
} catch (Exception e) { | |||||
warn("define generated class failed", e); | |||||
if (LangUtil.is11VMOrGreater()) { | |||||
try { | |||||
if (!initializedForJava11) { | |||||
initializeForJava11(); | |||||
} | |||||
// Do this: clazz = defineClassMethodHandle.bindTo(loader).invokeWithArguments(name, bytes, 0, bytes.length); | |||||
Object o = bindTo_Method.invoke(defineClassMethodHandle,loader); | |||||
clazz = invokeWithArguments_Method.invoke(o, new Object[] {new Object[] {name, bytes, 0, bytes.length}}); | |||||
} catch (Throwable t) { | |||||
t.printStackTrace(System.err); | |||||
warn("define generated class failed", t); | |||||
} | |||||
} else { | |||||
try { | |||||
if (defineClassMethod == null) { | |||||
synchronized (lock) { | |||||
getUnsafe(); | |||||
defineClassMethod = | |||||
Unsafe.class.getDeclaredMethod("defineClass", String.class,byte[].class,Integer.TYPE,Integer.TYPE, ClassLoader.class,ProtectionDomain.class); | |||||
} | |||||
} | |||||
defineClassMethod.setAccessible(true); | |||||
clazz = defineClassMethod.invoke(getUnsafe(), name,bytes,0,bytes.length,loader,protectionDomain); | |||||
} catch (LinkageError le) { | |||||
le.printStackTrace(); | |||||
// likely thrown due to defining something that already exists? | |||||
// Old comments from before moving to Unsafe.defineClass(): | |||||
// is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved) | |||||
// TODO maw I don't think this is OK and | |||||
} catch (Exception e) { | |||||
e.printStackTrace(System.err); | |||||
warn("define generated class failed", e); | |||||
} | |||||
} | } | ||||
if (trace.isTraceEnabled()) { | if (trace.isTraceEnabled()) { | ||||
trace.exit("defineClass", clazz); | trace.exit("defineClass", clazz); | ||||
} | } | ||||
} | } | ||||
static Method defineClassMethod; | |||||
private static String lock = "lock"; | |||||
// /* | |||||
// This method is equivalent to the following code but use reflection to compile on Java 7: | |||||
// MethodHandles.Lookup baseLookup = MethodHandles.lookup(); | |||||
// MethodHandles.Lookup lookup = MethodHandles.privateLookupIn(ClassLoader.class, baseLookup); | |||||
// MethodHandle defineClassMethodHandle = lookup.findVirtual(ClassLoader.class, "defineClass", defineClassMethodType); | |||||
// handle.bindTo(classLoader).invokeWithArguments(className, classBytes, 0, classBytes.length)); | |||||
// */ | |||||
//@Override | |||||
//@SuppressWarnings("unchecked") | |||||
//public <T> Class<T> defineClass(ClassLoader classLoader, String className, byte[] classBytes) { | |||||
// Object baseLookup = methodHandlesLookup.invoke(null); | |||||
// Object lookup = methodHandlesPrivateLookupIn.invoke(null, ClassLoader.class, baseLookup); | |||||
// MethodHandle defineClassMethodHandle = (MethodHandle) lookupFindVirtual.invoke(lookup, ClassLoader.class, "defineClass", defineClassMethodType); | |||||
// try { | |||||
// return Cast.uncheckedCast(defineClassMethodHandle.bindTo(classLoader).invokeWithArguments(className, classBytes, 0, classBytes.length)); | |||||
// } catch (Throwable throwable) { | |||||
// throw new RuntimeException(throwable); | |||||
// return (Class) defineClassMethodHandle.bindTo(classLoader).invokeWithArguments(className, classBytes, 0, classBytes.length); | |||||
// } catch (Throwable e) { | |||||
// throw new RuntimeException(e); | |||||
// } | |||||
//} | |||||
private void defineClass(ClassLoader loader, String name, byte[] bytes){ | |||||
defineClass(loader,name,bytes,null);//, ProtectionDomain protectionDomain) { | |||||
} | |||||
// if (trace.isTraceEnabled()) { | |||||
// trace.enter("defineClass", this, new Object[] { loader, name, bytes, protectionDomain }); | |||||
// } | |||||
// Object clazz = null; | |||||
// debug("generating class '" + name + "'"); | |||||
// try { | |||||
// getUnsafe().defineClass(name, bytes, 0, bytes.length, loader, protectionDomain); | |||||
// } catch (LinkageError le) { | |||||
// // likely thrown due to defining something that already exists? | |||||
// // Old comments from before moving to Unsafe.defineClass(): | |||||
// // is already defined (happens for X$ajcMightHaveAspect interfaces since aspects are reweaved) | |||||
// // TODO maw I don't think this is OK and | |||||
// } catch (Exception e) { | |||||
// warn("define generated class failed", e); | |||||
// } | |||||
// | |||||
// if (trace.isTraceEnabled()) { | |||||
// trace.exit("defineClass", clazz); | |||||
// } | |||||
// } | |||||
} | } |
} | } | ||||
/** | /** | ||||
* Build the bytecode for the concrete aspect | |||||
* | |||||
* @return concrete aspect bytecode | |||||
* @return the bytecode for the concrete aspect | |||||
*/ | */ | ||||
public byte[] getBytes() { | public byte[] getBytes() { | ||||
if (!isValid) { | if (!isValid) { |
The -Xlintfile:lint.properties allows fine-grained control. In tools.jar, see | The -Xlintfile:lint.properties allows fine-grained control. In tools.jar, see | ||||
org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. | org/aspectj/weaver/XlintDefault.properties for the default behavior and a template to copy. | ||||
### AspectJ-specific messages | ### AspectJ-specific messages | ||||
compiler.name = AspectJ Compiler 1.9.1 | |||||
compiler.version = Eclipse Compiler #abe06abe4ce1(Apr2018), 3.14 | |||||
compiler.name = AspectJ Compiler 1.9.2 | |||||
compiler.version = Eclipse Compiler #BETA_JAVA11(20Sep2018), 3.14 | |||||
compiler.copyright = | compiler.copyright = | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedMethodBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TagBits; | ||||
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; | import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; | ||||
import org.aspectj.weaver.ResolvedTypeMunger; | import org.aspectj.weaver.ResolvedTypeMunger; | ||||
import org.aspectj.weaver.Shadow; | import org.aspectj.weaver.Shadow; | ||||
import org.aspectj.weaver.UnresolvedType; | import org.aspectj.weaver.UnresolvedType; | ||||
import org.aspectj.weaver.patterns.Declare; | |||||
import org.aspectj.weaver.patterns.DeclareAnnotation; | import org.aspectj.weaver.patterns.DeclareAnnotation; | ||||
import org.aspectj.weaver.patterns.DeclareParents; | import org.aspectj.weaver.patterns.DeclareParents; | ||||
import org.aspectj.weaver.patterns.DeclareSoft; | import org.aspectj.weaver.patterns.DeclareSoft; | ||||
if (typeDecl.enclosingType != null && (typeDecl.enclosingType instanceof AspectDeclaration)) { | if (typeDecl.enclosingType != null && (typeDecl.enclosingType instanceof AspectDeclaration)) { | ||||
AspectDeclaration ad = (AspectDeclaration) typeDecl.enclosingType; | AspectDeclaration ad = (AspectDeclaration) typeDecl.enclosingType; | ||||
if (ad.concreteName != null) { | if (ad.concreteName != null) { | ||||
List declares = ad.concreteName.declares; | |||||
for (Iterator iter = declares.iterator(); iter.hasNext();) { | |||||
List<Declare> declares = ad.concreteName.declares; | |||||
for (Iterator<Declare> iter = declares.iterator(); iter.hasNext();) { | |||||
Object dec = iter.next(); | Object dec = iter.next(); | ||||
if (dec instanceof DeclareParents) { | if (dec instanceof DeclareParents) { | ||||
DeclareParents decp = (DeclareParents) dec; | DeclareParents decp = (DeclareParents) dec; | ||||
private final static char[] thisJoinPointStaticPartName = "thisJoinPointStaticPart".toCharArray(); | private final static char[] thisJoinPointStaticPartName = "thisJoinPointStaticPart".toCharArray(); | ||||
private final static char[] thisEnclosingJoinPointStaticPartName = "thisEnclosingJoinPointStaticPart".toCharArray(); | private final static char[] thisEnclosingJoinPointStaticPartName = "thisEnclosingJoinPointStaticPart".toCharArray(); | ||||
private final static char[] thisAspectInstanceName = "thisAspectInstance".toCharArray(); | private final static char[] thisAspectInstanceName = "thisAspectInstance".toCharArray(); | ||||
public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) { | |||||
@Override | |||||
public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location, Scope scope) { | |||||
if (CharOperation.equals(binding.name, thisJoinPointName) || | if (CharOperation.equals(binding.name, thisJoinPointName) || | ||||
CharOperation.equals(binding.name, thisJoinPointStaticPartName) || | CharOperation.equals(binding.name, thisJoinPointStaticPartName) || | ||||
CharOperation.equals(binding.name, thisAspectInstanceName) || | CharOperation.equals(binding.name, thisAspectInstanceName) || | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
super.uninitializedLocalVariable(binding, location); | |||||
super.uninitializedLocalVariable(binding, location, scope); | |||||
} | } | ||||
public void abstractMethodInConcreteClass(SourceTypeBinding type) { | public void abstractMethodInConcreteClass(SourceTypeBinding type) { |
private List<Classpath> processFilePath(List<File> path, java.lang.String encoding) { | private List<Classpath> processFilePath(List<File> path, java.lang.String encoding) { | ||||
List<Classpath> entries = new ArrayList<Classpath>(); | List<Classpath> entries = new ArrayList<Classpath>(); | ||||
for (File file: path) { | for (File file: path) { | ||||
entries.add(FileSystem.getClasspath(file.getAbsolutePath(), encoding, null, ClasspathLocation.BINARY)); | |||||
entries.add(FileSystem.getClasspath(file.getAbsolutePath(), encoding, null, ClasspathLocation.BINARY, null)); | |||||
} | } | ||||
return entries; | return entries; | ||||
} | } | ||||
private List<Classpath> processStringPath(List<String> path, java.lang.String encoding) { | private List<Classpath> processStringPath(List<String> path, java.lang.String encoding) { | ||||
List<Classpath> entries = new ArrayList<Classpath>(); | List<Classpath> entries = new ArrayList<Classpath>(); | ||||
for (String file: path) { | for (String file: path) { | ||||
entries.add(FileSystem.getClasspath(file, encoding, null, ClasspathLocation.BINARY)); | |||||
entries.add(FileSystem.getClasspath(file, encoding, null, ClasspathLocation.BINARY, null)); | |||||
} | } | ||||
return entries; | return entries; | ||||
} | } |
// 'classpaths' object it isn't recording where the code came from. This will be an issue later for | // 'classpaths' object it isn't recording where the code came from. This will be an issue later for | ||||
// weaving, the distinction will need to be maintained for proper 'module aware/respecting' weaving. | // weaving, the distinction will need to be maintained for proper 'module aware/respecting' weaving. | ||||
if (buildConfig.getCheckedClasspaths() == null) { | if (buildConfig.getCheckedClasspaths() == null) { | ||||
nameEnvironment = new FileSystem(classpaths, filenames, defaultEncoding, ClasspathLocation.BINARY); | |||||
nameEnvironment = new FileSystem(classpaths, filenames, defaultEncoding, ClasspathLocation.BINARY, null); | |||||
} else { | } else { | ||||
nameEnvironment = new FileSystem(buildConfig.getCheckedClasspaths(), filenames, false, null); | nameEnvironment = new FileSystem(buildConfig.getCheckedClasspaths(), filenames, false, null); | ||||
} | } |
import org.aspectj.bridge.IMessage; | import org.aspectj.bridge.IMessage; | ||||
import org.aspectj.tools.ajc.AjcTestCase; | import org.aspectj.tools.ajc.AjcTestCase; | ||||
import org.aspectj.tools.ajc.CompilationResult; | import org.aspectj.tools.ajc.CompilationResult; | ||||
import org.aspectj.util.LangUtil; | |||||
public class JavadocTest extends AjcTestCase { | public class JavadocTest extends AjcTestCase { | ||||
public static final String PROJECT_DIR = "javadoc"; | public static final String PROJECT_DIR = "javadoc"; | ||||
// Basically that the javadoc on a public member refers to something that is not public | // Basically that the javadoc on a public member refers to something that is not public | ||||
warningMessages.add(new Message(6,"'public' visibility for malformed doc comments hides this 'default' reference")); | warningMessages.add(new Message(6,"'public' visibility for malformed doc comments hides this 'default' reference")); | ||||
warningMessages.add(new Message(32,"'public' visibility for malformed doc comments hides this 'default' reference")); | warningMessages.add(new Message(32,"'public' visibility for malformed doc comments hides this 'default' reference")); | ||||
warningMessages.add(new Message(22,"'public' visibility for malformed doc comments hides this 'default' reference")); | |||||
warningMessages.add(new Message(48,"'public' visibility for malformed doc comments hides this 'default' reference")); | |||||
MessageSpec spec = new MessageSpec(warningMessages, null); | MessageSpec spec = new MessageSpec(warningMessages, null); | ||||
CompilationResult result = ajc(baseDir, args); | CompilationResult result = ajc(baseDir, args); |
+ File.separator | + File.separator | ||||
+ "bcel-verifier.jar" | + "bcel-verifier.jar" | ||||
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-6.1.1.renamed.jar" | |||||
+ File.pathSeparator + ".." + File.separator + "lib" + File.separator + "asm" + File.separator + "asm-6.2.1.renamed.jar" | |||||
// When the build machine executes the tests, it is using code built into jars rather than code build into | // 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: | // 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"; | 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", "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" }; | |||||
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", "11" }; | |||||
static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "9", "10", "11"}; | |||||
static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8", "-1.9", "-9", "-10", "-11" }; | |||||
private static final ICommandEditor COMMAND_EDITOR; | private static final ICommandEditor COMMAND_EDITOR; | ||||
private static boolean is18VMOrGreater = false; | private static boolean is18VMOrGreater = false; | ||||
private static boolean is19VMOrGreater = false; | private static boolean is19VMOrGreater = false; | ||||
private static boolean is10VMOrGreater = false; | private static boolean is10VMOrGreater = false; | ||||
private static boolean is11VMOrGreater = false; | |||||
static { // matching logic is also in org.aspectj.util.LangUtil | static { // matching logic is also in org.aspectj.util.LangUtil | ||||
is14VMOrGreater = LangUtil.is14VMOrGreater(); | is14VMOrGreater = LangUtil.is14VMOrGreater(); | ||||
is18VMOrGreater = LangUtil.is18VMOrGreater(); | is18VMOrGreater = LangUtil.is18VMOrGreater(); | ||||
is19VMOrGreater = LangUtil.is19VMOrGreater(); | is19VMOrGreater = LangUtil.is19VMOrGreater(); | ||||
is10VMOrGreater = LangUtil.is10VMOrGreater(); | is10VMOrGreater = LangUtil.is10VMOrGreater(); | ||||
is11VMOrGreater = LangUtil.is11VMOrGreater(); | |||||
} | } | ||||
private List<ITestStep> testSteps = new ArrayList<ITestStep>(); | private List<ITestStep> testSteps = new ArrayList<ITestStep>(); | ||||
if (vmLevel.equals("1.8")) canRun = is18VMOrGreater; | if (vmLevel.equals("1.8")) canRun = is18VMOrGreater; | ||||
if (vmLevel.equals("1.9")) canRun = is19VMOrGreater; | if (vmLevel.equals("1.9")) canRun = is19VMOrGreater; | ||||
if (vmLevel.equals("10")) canRun = is10VMOrGreater; | if (vmLevel.equals("10")) canRun = is10VMOrGreater; | ||||
if (vmLevel.equals("11")) canRun = is11VMOrGreater; | |||||
if (!canRun) { | if (!canRun) { | ||||
System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel() | System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel() | ||||
+ ", currently running on " + System.getProperty("java.vm.version")); | + ", currently running on " + System.getProperty("java.vm.version")); |
if (stderr2.indexOf("Class JavaLaunchHelper is implemented in both")!=-1 && stderr2.indexOf('\n')!=-1) { | if (stderr2.indexOf("Class JavaLaunchHelper is implemented in both")!=-1 && stderr2.indexOf('\n')!=-1) { | ||||
stderr2 = stderr2.replaceAll("objc\\[[0-9]*\\]: Class JavaLaunchHelper is implemented in both [^\n]*\n",""); | stderr2 = stderr2.replaceAll("objc\\[[0-9]*\\]: Class JavaLaunchHelper is implemented in both [^\n]*\n",""); | ||||
} | } | ||||
// JDK 11 is complaining about illegal reflective calls - temporary measure ignore these - does that get all tests passing and this is the last problem? | |||||
if (stderr2.indexOf("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor") != -1) { | |||||
// WARNING: An illegal reflective access operation has occurred | |||||
// WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor (file:/Users/aclement/gits/org.aspectj/loadtime/bin/) to class java.lang.ClassLoader | |||||
// WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor | |||||
// WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations | |||||
// WARNING: All illegal access operations will be denied in a future release | |||||
stderr2 = stderr2.replaceAll("WARNING: An illegal reflective access operation has occurred\n",""); | |||||
stderr2 = stderr2.replaceAll("WARNING: Illegal reflective access using Lookup on org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor[^\n]*\n",""); | |||||
stderr2 = stderr2.replaceAll("WARNING: Please consider reporting this to the maintainers of org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor\n",""); | |||||
stderr2 = stderr2.replaceAll("WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations\n",""); | |||||
stderr2 = stderr2.replaceAll("WARNING: All illegal access operations will be denied in a future release\n",""); | |||||
} | |||||
m_stdErrSpec.matchAgainst(stderr2); | m_stdErrSpec.matchAgainst(stderr2); | ||||
} | } | ||||
} | } |
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.testing; | package org.aspectj.testing; | ||||
import org.aspectj.util.LangUtil; | |||||
/** | /** | ||||
* Makes sure tests are running on the right level of JDK. | |||||
* Ensure sure tests are running on the right level of JDK. | |||||
* | * | ||||
* @author Andy Clement | * @author Andy Clement | ||||
*/ | */ | ||||
@Override | @Override | ||||
public void runTest(String title) { | public void runTest(String title) { | ||||
// Check we are on Java10 | |||||
String property = System.getProperty("java.version"); | |||||
if (!property.startsWith("10")) { | |||||
if (!LangUtil.is10VMOrGreater()) { | |||||
throw new IllegalStateException("These tests should be run on Java 10 or later"); | throw new IllegalStateException("These tests should be run on Java 10 or later"); | ||||
} | } | ||||
super.runTest(title); | super.runTest(title); |
/* ******************************************************************* | |||||
* 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 XMLBasedAjcTestCaseForJava11OrLater extends XMLBasedAjcTestCase { | |||||
@Override | |||||
public void runTest(String title) { | |||||
// Check we are on Java11 | |||||
String property = System.getProperty("java.version"); | |||||
if (!property.startsWith("11")) { | |||||
throw new IllegalStateException("These tests should be run on Java 11 or later"); | |||||
} | |||||
super.runTest(title); | |||||
} | |||||
} |
import org.aspectj.lang.annotation.*; | |||||
public class DemoApp { | |||||
public static void main(String[]argv) {} | |||||
private void recurseInsteadOfWhile() { | |||||
say(); | |||||
} | |||||
public void say() { } | |||||
} | |||||
aspect X { // mixed style here... | |||||
@Around("call(public void DemoApp+.say(..))") | |||||
public void y() {} | |||||
} |
import org.aspectj.lang.annotation.*; | |||||
public class DemoApp2 { | |||||
public static void main(String[]argv) {} | |||||
private void recurseInsteadOfWhile() { | |||||
say(); | |||||
} | |||||
public void say() { } | |||||
} | |||||
aspect X { | |||||
void around(): call(public void DemoApp2+.say(..)) { | |||||
} | |||||
} |
public class Code { | |||||
public static void main(String[] args) { | |||||
A.methodA(); | |||||
} | |||||
} | |||||
class A { | |||||
public static void methodA() { | |||||
B.methodB(); | |||||
} | |||||
} | |||||
class B { | |||||
public static void methodB() { | |||||
C.methodC(); | |||||
int a = 1; | |||||
int b = 2; | |||||
System.out.println( a + b ); | |||||
} | |||||
} | |||||
class C { | |||||
public static void methodC() { | |||||
D.methodD(); | |||||
} | |||||
} | |||||
class D { | |||||
public static void methodD() { | |||||
} | |||||
} | |||||
aspect CFlow { | |||||
public pointcut flow() : cflow(call( * B.methodB() ) ) && !within(CFlow); | |||||
before() : flow() { | |||||
System.out.println( thisJoinPoint ); | |||||
} | |||||
} | |||||
import org.aspectj.systemtest.ajc190.AllTestsAspectJ190; | import org.aspectj.systemtest.ajc190.AllTestsAspectJ190; | ||||
import org.aspectj.systemtest.ajc191.AllTestsAspectJ191; | import org.aspectj.systemtest.ajc191.AllTestsAspectJ191; | ||||
import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; | import org.aspectj.systemtest.ajc192.AllTestsAspectJ192; | ||||
import org.aspectj.systemtest.ajc193.AllTestsAspectJ193; | |||||
import junit.framework.Test; | import junit.framework.Test; | ||||
import junit.framework.TestSuite; | import junit.framework.TestSuite; | ||||
suite.addTest(AllTestsAspectJ190.suite()); | suite.addTest(AllTestsAspectJ190.suite()); | ||||
suite.addTest(AllTestsAspectJ191.suite()); | suite.addTest(AllTestsAspectJ191.suite()); | ||||
suite.addTest(AllTestsAspectJ192.suite()); | suite.addTest(AllTestsAspectJ192.suite()); | ||||
suite.addTest(AllTestsAspectJ193.suite()); | |||||
suite.addTest(AllTests18.suite()); | suite.addTest(AllTests18.suite()); | ||||
// $JUnit-END$ | // $JUnit-END$ | ||||
return suite; | return suite; |
</ajc-test> | </ajc-test> | ||||
<ajc-test dir="bugs180/415957" title="annotations with 1.8 flags"> | <ajc-test dir="bugs180/415957" title="annotations with 1.8 flags"> | ||||
<compile files="MyAspect.aj MyClass.java" options="-1.8 -showWeaveInfo"> | |||||
<compile files="MyAspect.aj MyClass.java Resource.java" options="-1.8 -showWeaveInfo"> | |||||
<message kind="weave" text="Join point 'method-execution(void MyClass.method())' in Type 'MyClass' (MyClass.java:3) advised by before advice from 'MyAspect' (MyAspect.aj:5)"/> | <message kind="weave" text="Join point 'method-execution(void MyClass.method())' in Type 'MyClass' (MyClass.java:3) advised by before advice from 'MyAspect' (MyAspect.aj:5)"/> | ||||
</compile> | </compile> | ||||
</ajc-test> | </ajc-test> |
import java.io.File; | import java.io.File; | ||||
import org.aspectj.apache.bcel.Constants; | |||||
import org.aspectj.apache.bcel.classfile.Attribute; | |||||
import org.aspectj.apache.bcel.classfile.JavaClass; | import org.aspectj.apache.bcel.classfile.JavaClass; | ||||
import org.aspectj.apache.bcel.classfile.Method; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | import org.aspectj.testing.XMLBasedAjcTestCase; | ||||
import org.aspectj.weaver.ResolvedMember; | import org.aspectj.weaver.ResolvedMember; | ||||
import org.aspectj.weaver.ResolvedType; | import org.aspectj.weaver.ResolvedType; |
import org.aspectj.apache.bcel.classfile.Method; | import org.aspectj.apache.bcel.classfile.Method; | ||||
import org.aspectj.testing.XMLBasedAjcTestCase; | import org.aspectj.testing.XMLBasedAjcTestCase; | ||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater; | import org.aspectj.testing.XMLBasedAjcTestCaseForJava9OrLater; | ||||
import org.aspectj.util.LangUtil; | |||||
import junit.framework.Test; | import junit.framework.Test; | ||||
// This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK) | // This tests that when using --add-modules with one of the JDK modules (in the jmods subfolder of the JDK) | ||||
// that it can be found without needing to set --module-path (this seems to be implicitly included by javac too) | // that it can be found without needing to set --module-path (this seems to be implicitly included by javac too) | ||||
public void testAddModules1() { | public void testAddModules1() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
// java.xml.bind is gone in Java11 | |||||
return; | |||||
} | |||||
runTest("compile use of java.xml.bind"); | runTest("compile use of java.xml.bind"); | ||||
} | } | ||||
// This tests that we can use add-modules to pull in something from the JDK jmods package and that | // This tests that we can use add-modules to pull in something from the JDK jmods package and that | ||||
// when subsequently weaving we can see types from those modules | // when subsequently weaving we can see types from those modules | ||||
public void testWovenAfterAddModules() { | public void testWovenAfterAddModules() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
// java.xml.bind is gone in Java11 | |||||
return; | |||||
} | |||||
runTest("weave use of java.xml.bind"); | runTest("weave use of java.xml.bind"); | ||||
} | } | ||||
// --limit-modules | // --limit-modules | ||||
public void testLimitModules1() { | public void testLimitModules1() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
// java.xml.bind is gone in Java11 | |||||
return; | |||||
} | |||||
runTest("limit modules 1"); | runTest("limit modules 1"); | ||||
} | } | ||||
// --add-reads | // --add-reads | ||||
public void testAddReads1() { | public void testAddReads1() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
// java.xml.bind is gone in Java11 | |||||
return; | |||||
} | |||||
runTest("add reads 1"); | runTest("add reads 1"); | ||||
} | } | ||||
runTest("no final on cflow elements"); | runTest("no final on cflow elements"); | ||||
} | } | ||||
public void testAroundAdvice_AnnoStyle() { | |||||
// TODO Still to be fixed, the workaround to not mix style is good enough for now... | |||||
public void xtestAroundAdvice_AnnoStyle() { | |||||
runTest("around advice"); | runTest("around advice"); | ||||
} | } | ||||
TestSuite suite = new TestSuite("AspectJ 1.9.2 tests"); | TestSuite suite = new TestSuite("AspectJ 1.9.2 tests"); | ||||
// $JUnit-BEGIN$ | // $JUnit-BEGIN$ | ||||
suite.addTest(Ajc192Tests.suite()); | suite.addTest(Ajc192Tests.suite()); | ||||
suite.addTest(SanityTestsJava11.suite()); | |||||
// $JUnit-END$ | // $JUnit-END$ | ||||
return suite; | return suite; | ||||
} | } |
/******************************************************************************* | |||||
* Copyright (c) 2006, 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 | |||||
*******************************************************************************/ | |||||
package org.aspectj.systemtest.ajc192; | |||||
import java.io.File; | |||||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava11OrLater; | |||||
import junit.framework.Test; | |||||
/* | |||||
* Some very trivial tests that help verify things are OK. | |||||
* These are a copy of the earlier Sanity Tests created for 1.6 but these supply the -10 option | |||||
* to check code generation and modification with that version specified. | |||||
* | |||||
* @author Andy Clement | |||||
*/ | |||||
public class SanityTestsJava11 extends XMLBasedAjcTestCaseForJava11OrLater { | |||||
// Incredibly trivial test programs that check the compiler works at all (these are easy-ish to debug) | |||||
public void testSimpleJava_A() { | |||||
runTest("simple - a"); | |||||
} | |||||
public void testSimpleJava_B() { | |||||
runTest("simple - b"); | |||||
} | |||||
public void testSimpleCode_C() { | |||||
runTest("simple - c"); | |||||
} | |||||
public void testSimpleCode_D() { | |||||
runTest("simple - d"); | |||||
} | |||||
public void testSimpleCode_E() { | |||||
runTest("simple - e"); | |||||
} | |||||
public void testSimpleCode_F() { | |||||
runTest("simple - f"); | |||||
} | |||||
public void testSimpleCode_G() { | |||||
runTest("simple - g"); | |||||
} | |||||
public void testSimpleCode_H() { | |||||
runTest("simple - h", true); | |||||
} | |||||
public void testSimpleCode_I() { | |||||
runTest("simple - i"); | |||||
} | |||||
public void testVersionCorrect1() throws ClassNotFoundException { | |||||
runTest("simple - j"); | |||||
checkVersion("A", 55, 0); | |||||
} | |||||
public void testVersionCorrect2() throws ClassNotFoundException { | |||||
runTest("simple - k"); | |||||
checkVersion("A", 55, 0); | |||||
} | |||||
public void testVersionCorrect4() throws ClassNotFoundException { // check it is 49.0 when -1.5 is specified | |||||
runTest("simple - m"); | |||||
checkVersion("A", 49, 0); | |||||
} | |||||
private void checkVersion(String classname, int major, int minor) throws ClassNotFoundException { | |||||
JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), classname); | |||||
if (jc.getMajor() != major) { | |||||
fail("Expected major version to be " + major + " but was " + jc.getMajor()); | |||||
} | |||||
if (jc.getMinor() != minor) { | |||||
fail("Expected minor version to be " + minor + " but was " + jc.getMinor()); | |||||
} | |||||
} | |||||
// /////////////////////////////////////// | |||||
public static Test suite() { | |||||
return XMLBasedAjcTestCase.loadSuite(SanityTestsJava11.class); | |||||
} | |||||
@Override | |||||
protected File getSpecFile() { | |||||
return getClassResource("sanity-tests-11.xml"); | |||||
} | |||||
} |
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> | |||||
<suite> | |||||
<!-- empty class --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - a"> | |||||
<compile files="SimpleA.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- class with one method --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - b"> | |||||
<compile files="SimpleB.java" options="-11"/> | |||||
<run class="SimpleB"/> | |||||
</ajc-test> | |||||
<!-- empty aspect --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - c"> | |||||
<compile files="SimpleC.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- simple before --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - d"> | |||||
<compile files="SimpleD.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- simple itd field --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - e"> | |||||
<compile files="SimpleE.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- aspect with main calling a static method --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - f"> | |||||
<compile files="SimpleF.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- pertarget --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - g"> | |||||
<compile files="SimpleG.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- generic ctor itds --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - h"> | |||||
<compile files="SimpleH.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- overriding generic itd methods --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - i"> | |||||
<compile files="SimpleI.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 54.0 --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - j"> | |||||
<compile files="SimpleJ.java" options="-11"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 54.0 --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - k"> | |||||
<compile files="SimpleJ.java" options="-source 11"/> | |||||
</ajc-test> | |||||
<!-- check class file version is 49.0 --> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - m"> | |||||
<compile files="SimpleJ.java" options="-1.5"/> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs160/simplejava" title="simple - n"> | |||||
<compile files="SimpleN.java" options="-11"/> | |||||
</ajc-test> | |||||
</suite> |
/******************************************************************************* | |||||
* 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.ajc193; | |||||
import java.io.File; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | |||||
import org.aspectj.testing.XMLBasedAjcTestCaseForJava10OrLater; | |||||
import junit.framework.Test; | |||||
/** | |||||
* @author Andy Clement | |||||
*/ | |||||
public class Ajc193Tests extends XMLBasedAjcTestCaseForJava10OrLater { | |||||
// --- | |||||
public static Test suite() { | |||||
return XMLBasedAjcTestCase.loadSuite(Ajc193Tests.class); | |||||
} | |||||
@Override | |||||
protected File getSpecFile() { | |||||
return getClassResource("ajc193.xml"); | |||||
} | |||||
} |
/******************************************************************************* | |||||
* 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.ajc193; | |||||
import junit.framework.Test; | |||||
import junit.framework.TestSuite; | |||||
public class AllTestsAspectJ193 { | |||||
public static Test suite() { | |||||
TestSuite suite = new TestSuite("AspectJ 1.9.3 tests"); | |||||
// $JUnit-BEGIN$ | |||||
suite.addTest(Ajc193Tests.suite()); | |||||
// $JUnit-END$ | |||||
return suite; | |||||
} | |||||
} |
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]> | |||||
<suite> | |||||
<!-- | |||||
<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.lang.String"/> | |||||
</stdout> | |||||
</run> | |||||
</ajc-test> | |||||
--> | |||||
</suite> |
} | } | ||||
public void testDisabledApt() { | public void testDisabledApt() { | ||||
if (LangUtil.is11VMOrGreater()) { | |||||
// javax.annotation.Generated not in Java11 | |||||
return; | |||||
} | |||||
runTest("disabled annotation processing"); | runTest("disabled annotation processing"); | ||||
} | } | ||||
*/ | */ | ||||
public class CompilerFactory { | public class CompilerFactory { | ||||
private static Map compilerMap = new Hashtable(); | |||||
private static Map<String,AjCompiler> compilerMap = new Hashtable<>(); | |||||
/** | /** | ||||
* If an AjCompiler exists for the given projectDir then returns | * If an AjCompiler exists for the given projectDir then returns | ||||
* IncrementalStateManager) | * IncrementalStateManager) | ||||
*/ | */ | ||||
public static void clearCompilerMap() { | public static void clearCompilerMap() { | ||||
Collection compilers = compilerMap.values(); | |||||
for (Iterator iterator = compilers.iterator(); iterator.hasNext();) { | |||||
AjCompiler compiler = (AjCompiler) iterator.next(); | |||||
Collection<AjCompiler> compilers = compilerMap.values(); | |||||
for (AjCompiler compiler: compilers) { | |||||
compiler.clearLastState(); | compiler.clearLastState(); | ||||
} | } | ||||
compilerMap.clear(); | compilerMap.clear(); |
return 10 <= vmVersion; | return 10 <= vmVersion; | ||||
} | } | ||||
public static boolean is11VMOrGreater() { | |||||
return 11 <= vmVersion; | |||||
} | |||||
/** | /** | ||||
* Shorthand for "if null, throw IllegalArgumentException" | * Shorthand for "if null, throw IllegalArgumentException" | ||||
* | * |
UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection"); | UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection"); | ||||
world.resolve(collectionType).getRawType().resolve(world); | world.resolve(collectionType).getRawType().resolve(world); | ||||
ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods(); | ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods(); | ||||
int i = findMethod("toArray", 1, methods); | |||||
int i = -1; | |||||
for (int j=0;j<methods.length;j++) { | |||||
ResolvedMember method = methods[j]; | |||||
if (method.getName().equals("toArray") && method.getParameterSignature().equals("([TT;)")) { | |||||
i = j; | |||||
} | |||||
} | |||||
assertTrue("Couldn't find 'toArray' in the set of methods? ", i != -1); | assertTrue("Couldn't find 'toArray' in the set of methods? ", i != -1); | ||||
// String expectedSignature = "java.lang.Object[] java.util.Collection.toArray(java.lang.Object[])"; | // String expectedSignature = "java.lang.Object[] java.util.Collection.toArray(java.lang.Object[])"; | ||||
String expectedSignature = "([Ljava/lang/Object;)[Ljava/lang/Object;"; | String expectedSignature = "([Ljava/lang/Object;)[Ljava/lang/Object;"; | ||||
assertTrue("Expected signature of '" + expectedSignature + "' but it was '" + methods[i].getSignatureErased(), methods[i] | assertTrue("Expected signature of '" + expectedSignature + "' but it was '" + methods[i].getSignatureErased(), methods[i] | ||||
.getSignatureErased().equals(expectedSignature)); | .getSignatureErased().equals(expectedSignature)); | ||||
} | } |