StringBuilder buf = new StringBuilder(); | StringBuilder buf = new StringBuilder(); | ||||
buf.append("("); | buf.append("("); | ||||
for (UnresolvedType paramType : paramTypes) { | for (UnresolvedType paramType : paramTypes) { | ||||
if (eraseGenerics && (paramType.isParameterizedType() || paramType.isTypeVariableReference())) { | |||||
if (eraseGenerics) { | |||||
buf.append(paramType.getErasureSignature()); | buf.append(paramType.getErasureSignature()); | ||||
} else { | } else { | ||||
buf.append(paramType.getSignature()); | buf.append(paramType.getSignature()); | ||||
} | } | ||||
} | } | ||||
buf.append(")"); | buf.append(")"); | ||||
if (eraseGenerics && (returnType.isParameterizedType() || returnType.isTypeVariableReference())) { | |||||
if (eraseGenerics) { | |||||
buf.append(returnType.getErasureSignature()); | buf.append(returnType.getErasureSignature()); | ||||
} else { | } else { | ||||
buf.append(returnType.getSignature()); | buf.append(returnType.getSignature()); |
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.testing; | package org.aspectj.testing; | ||||
import java.io.BufferedInputStream; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.FilenameFilter; | import java.io.FilenameFilter; | ||||
ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path")); | ClassPath cp = new ClassPath(cpentry + File.pathSeparator + System.getProperty("java.class.path")); | ||||
return SyntheticRepository.getInstance(cp); | return SyntheticRepository.getInstance(cp); | ||||
} | } | ||||
protected byte[] loadFileAsByteArray(File f) { | |||||
try { | |||||
byte[] bs = new byte[100000]; | |||||
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f)); | |||||
int pos = 0; | |||||
int len = 0; | |||||
while ((len=bis.read(bs, pos, 100000-pos))!=-1) { | |||||
pos+=len; | |||||
} | |||||
bis.close(); | |||||
return bs; | |||||
} catch (Exception e) { | |||||
return null; | |||||
} | |||||
} | |||||
public JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException { | public JavaClass getClassFrom(File where, String clazzname) throws ClassNotFoundException { | ||||
SyntheticRepository repos = createRepos(where); | SyntheticRepository repos = createRepos(where); |
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
@Bar(String) | |||||
@Foo("abc") | |||||
public class Code2 { | |||||
} | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@interface Foo { String value();} | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@interface Bar { | |||||
Class<?>[] value(); | |||||
} |
import java.lang.annotation.Retention; | |||||
import java.lang.annotation.RetentionPolicy; | |||||
@Bar(value=String,i=4) | |||||
//@Foo("abc") | |||||
public class Code3 { | |||||
} | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@interface Foo { String value();} | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@interface Bar { | |||||
Class<?>[] value(); | |||||
int i(); | |||||
} |
public class DummyClass { | |||||
@LogMe | |||||
public void doSomething() { | |||||
SampleUtil sampleUtil = new SampleUtil(); | |||||
// pass null for simplicity ! | |||||
sampleUtil.sampleMethod(null); | |||||
System.out.println("Do Something"); | |||||
} | |||||
public static void main(String[] args) { | |||||
new DummyClass().doSomething(); | |||||
} | |||||
} |
import java.lang.annotation.*; | |||||
@Retention(RetentionPolicy.RUNTIME) | |||||
@Target(ElementType.METHOD) | |||||
public @interface LogMe {} |
import org.aspectj.lang.JoinPoint; | |||||
import org.aspectj.lang.annotation.*; | |||||
aspect SampleAspect { | |||||
//@Aspect public class SampleAspect { | |||||
//@Before("@annotation(logMe)") public void beforeAdvice(JoinPoint thisJoinPoint, LogMe logMe) { | |||||
before(LogMe logMe): @annotation(logMe) { | |||||
System.out.println(thisJoinPoint); | |||||
} | |||||
} |
import java.util.Map; | |||||
public class SampleUtil { | |||||
public void sampleMethod(Map<String, Object>[] mapArray) {} | |||||
} |
public class Code { | |||||
public static void run() { | |||||
System.out.println("run() running"); | |||||
} | |||||
} |
aspect X { | |||||
before(): execution(* run(..)) { | |||||
System.out.println("advice runnning"); | |||||
} | |||||
} |
aspect X { | |||||
before(): execution(* run(..)) { | |||||
System.out.println("advice running"); | |||||
} | |||||
} |
*******************************************************************************/ | *******************************************************************************/ | ||||
package org.aspectj.systemtest.ajc185; | package org.aspectj.systemtest.ajc185; | ||||
import java.io.BufferedInputStream; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | |||||
import junit.framework.Test; | import junit.framework.Test; | ||||
import org.aspectj.apache.bcel.classfile.JavaClass; | |||||
import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen; | |||||
import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader; | |||||
import org.aspectj.testing.XMLBasedAjcTestCase; | import org.aspectj.testing.XMLBasedAjcTestCase; | ||||
/** | /** | ||||
*/ | */ | ||||
public class Ajc185Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | public class Ajc185Tests extends org.aspectj.testing.XMLBasedAjcTestCase { | ||||
public void testUnresolvableMember_456357() throws Exception { | |||||
runTest("unresolvable member"); | |||||
} | |||||
// Waiting on JDT fix. Second test is a 'variant' that is also causing me issues but not JDT it seems. Let's | |||||
// see what happens when we pick up the real fixes. | |||||
// public void testBadAnnos_455608() throws Exception { | |||||
// runTest("bad annos"); | |||||
// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code2"); | |||||
// File f = new File(ajc.getSandboxDirectory(), "Code2.class"); | |||||
// byte[] data = loadFileAsByteArray(f); | |||||
// // Will throw ClassFormatException if there is a problem | |||||
// new ClassFileReader(data, null); | |||||
// } | |||||
// | |||||
// public void testBadAnnos_455608_2() throws Exception { | |||||
// runTest("bad annos 2"); | |||||
// JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "Code3"); | |||||
// File f = new File(ajc.getSandboxDirectory(), "Code3.class"); | |||||
// byte[] data = loadFileAsByteArray(f); | |||||
// // Will throw ClassFormatException if there is a problem | |||||
// new ClassFileReader(data, null); | |||||
// } | |||||
public void testITDInterface_451966() throws Exception { | public void testITDInterface_451966() throws Exception { | ||||
runTest("itd interface"); | runTest("itd interface"); | ||||
} | } |
<suite> | <suite> | ||||
<ajc-test dir="bugs185/456357" title="unresolvable member"> | |||||
<compile files="DummyClass.java LogMe.java SampleAspect.java SampleUtil.java" options="-1.7"> | |||||
</compile> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs185/455608" title="bad annos"> | |||||
<compile files="Code2.java" options="-1.8 -proceedOnError"> | |||||
<message kind="error" text="String cannot be resolved to a variable"/> | |||||
</compile> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs185/455608" title="bad annos 2"> | |||||
<compile files="Code3.java" options="-1.8 -proceedOnError"> | |||||
<message kind="error" text="String cannot be resolved to a variable"/> | |||||
</compile> | |||||
</ajc-test> | |||||
<ajc-test dir="bugs185/451966" title="itd interface"> | <ajc-test dir="bugs185/451966" title="itd interface"> | ||||
<compile files="Code.java" options="-1.8"/> | <compile files="Code.java" options="-1.8"/> | ||||
<run class="Code"> | <run class="Code"> |
build("PR154054"); | build("PR154054"); | ||||
checkWasntFullBuild(); | checkWasntFullBuild(); | ||||
} | } | ||||
public void testIncrementalBuildAdviceChange_456801() throws Exception { | |||||
initialiseProject("456801"); | |||||
build("456801"); | |||||
String output = runMethod("456801", "Code", "run"); | |||||
assertEquals("advice runnning\nrun() running\n",output); | |||||
alter("456801", "inc1"); | |||||
build("456801"); | |||||
output = runMethod("456801", "Code", "run"); | |||||
assertEquals("advice running\nrun() running\n",output); | |||||
checkCompileWeaveCount("456801", 1, 1); | |||||
checkWasntFullBuild(); | |||||
} | |||||
// change exception type in around advice, does it notice? | // change exception type in around advice, does it notice? | ||||
public void testShouldFullBuildOnExceptionChange_pr154054() { | public void testShouldFullBuildOnExceptionChange_pr154054() { |