Browse Source

Merge branch 'BETA_JAVA8'

Conflicts:
	build/usedForMavenUpload/aspectjrt.pom
	build/usedForMavenUpload/aspectjtools.pom
	build/usedForMavenUpload/aspectjweaver.pom
	docs/dist/doc/README-174.html
	docs/dist/doc/index.html
	lib/asm/build.xml
	org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
	weaver/.classpath
	weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java
tags/V1_8_1
Andy Clement 10 years ago
parent
commit
144a629488
78 changed files with 878 additions and 277 deletions
  1. 0
    1
      .gitignore
  2. 1
    3
      ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java
  3. 2
    2
      build/build.xml
  4. 12
    0
      build/local.properties
  5. 2
    2
      build/products/aspectj/install/intro.html
  6. 2
    2
      build/src/$installer$/org/aspectj/Main.java
  7. 1
    1
      build/usedForMavenUpload/aspectjrt.pom
  8. 1
    1
      build/usedForMavenUpload/aspectjtools.pom
  9. 1
    1
      build/usedForMavenUpload/aspectjweaver.pom
  10. 1
    1
      build/usedForMavenUpload_milestone/aspectjrt.pom
  11. 1
    1
      build/usedForMavenUpload_milestone/aspectjtools.pom
  12. 1
    1
      build/usedForMavenUpload_milestone/aspectjweaver.pom
  13. 92
    0
      docs/dist/doc/README-180.html
  14. 1
    0
      docs/dist/doc/index.html
  15. 1
    1
      docs/install/intro.html
  16. BIN
      lib/asm/asm-5.0.1.jar
  17. BIN
      lib/asm/asm-5.0.1.renamed.jar
  18. 3
    3
      lib/asm/build.xml
  19. BIN
      lib/build/build.jar
  20. 3
    3
      loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java
  21. 3
    3
      loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
  22. 4
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
  23. 5
    4
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
  24. 1
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
  25. 1
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java
  26. 6
    4
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java
  27. 4
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java
  28. 1
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java
  29. 9
    2
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
  30. 2
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java
  31. 1
    1
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
  32. 4
    3
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java
  33. 16
    3
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
  34. 10
    10
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java
  35. 7
    0
      org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java
  36. 29
    20
      org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
  37. 4
    0
      org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
  38. 239
    137
      org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java
  39. 3
    5
      org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java
  40. 0
    2
      org.aspectj.matcher/src/org/aspectj/weaver/World.java
  41. 8
    2
      org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java
  42. 0
    5
      org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java
  43. 9
    2
      org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java
  44. 7
    2
      org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java
  45. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip
  46. BIN
      org.eclipse.jdt.core/jdtcore-for-aspectj.jar
  47. 3
    3
      taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java
  48. 13
    4
      taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java
  49. 12
    10
      testing/newsrc/org/aspectj/testing/AjcTest.java
  50. 8
    0
      tests/bugs180/415957/MyAspect.aj
  51. 5
    0
      tests/bugs180/415957/MyClass.java
  52. 9
    0
      tests/bugs180/432178/A.java
  53. 7
    0
      tests/bugs180/432178/B.java
  54. 11
    0
      tests/bugs180/432178/PerCFlowBug.java
  55. 9
    0
      tests/bugs180/432178/aop.xml
  56. 45
    0
      tests/bugs180/firstprogram/C.java
  57. 16
    0
      tests/bugs180/pr431541/Test.aj
  58. 10
    0
      tests/bugs180/pr431976/Code.java
  59. 25
    0
      tests/bugs180/pr432714/Code.java
  60. 2
    2
      tests/features152/synchronization/transformed/expected/Investigation.c.txt
  61. 2
    2
      tests/features152/synchronization/transformed/expected/One.c.txt
  62. 2
    2
      tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml
  63. 30
    0
      tests/src/org/aspectj/systemtest/AllTests18.java
  64. 4
    3
      tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
  65. 2
    1
      tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java
  66. 2
    2
      tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java
  67. 2
    0
      tests/src/org/aspectj/systemtest/ajc153/ajc153.xml
  68. 4
    2
      tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java
  69. 1
    1
      tests/src/org/aspectj/systemtest/ajc170/ajc170.xml
  70. 59
    0
      tests/src/org/aspectj/systemtest/ajc180/Ajc180Tests.java
  71. 25
    0
      tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java
  72. 55
    0
      tests/src/org/aspectj/systemtest/ajc180/ajc180.xml
  73. 4
    1
      tests/testsrc/org/aspectj/tests/TestsModuleTests.java
  74. 0
    1
      util/src/org/aspectj/util/FuzzyBoolean.java
  75. 5
    1
      util/src/org/aspectj/util/LangUtil.java
  76. 1
    1
      weaver/.classpath
  77. 1
    3
      weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
  78. 6
    3
      weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java

+ 0
- 1
.gitignore View File

@@ -1,3 +1,2 @@
*/bin
aj-build/
build/local.properties

+ 1
- 3
ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java View File

@@ -301,9 +301,7 @@ public class AjdeCoreBuildManager {
Map jom = compilerConfig.getJavaOptionsMap();
if (jom != null) {
String version = (String) jom.get(CompilerOptions.OPTION_Compliance);
if (version != null
&& (version.equals(CompilerOptions.VERSION_1_5) || version.equals(CompilerOptions.VERSION_1_6) || version
.equals(CompilerOptions.VERSION_1_7))) {
if (version != null && !version.equals(CompilerOptions.VERSION_1_4)) {
config.setBehaveInJava5Way(true);
}
config.getOptions().set(jom);

+ 2
- 2
build/build.xml View File

@@ -836,9 +836,9 @@ ant -propertyfile XXX publishtomaven


<target name="publishtomaven_milestone" depends="maven.init">
<property name="suffix" value="1.6.12.M1"/>
<property name="suffix" value="1.8.0.M1"/>

<property name="build.root" value="/Users/aclement/workspaces/aspectj1/aj-build"/>
<property name="build.root" value="/Users/aclement/gits/org.aspectj/aj-build"/>
<property name="adjusted.release.type" value="milestone"/>
<property name="maven.central.repository" value="s3://maven.springframework.org/${adjusted.release.type}"/>
<property name="bin.jars.folder" value="${build.root}/dist/tools/lib"/>

+ 12
- 0
build/local.properties View File

@@ -0,0 +1,12 @@
# for non-release builds, versions should all be DEVELOPMENT
# except for build.version.base
build.version=1.8.0.M1
build.version.base=1.8
build.version.long=1.8.0.M1
build.version.short=1.8.0.M1
# Repo version is for maven (as built with 'ant repo')
repo.version=1.6.4
java11.home=c:/home/apps/jdk11
java13.home=c:/home/apps/jdk13
java14.home=c:/home/apps/jdk14
java15.home=c:/home/apps/jdk15

+ 2
- 2
build/products/aspectj/install/intro.html View File

@@ -1,10 +1,10 @@
<html>
<body>

<h2 align="center">Installer for AspectJ 6 Development Kit<sup><small>TM</small></sup></h2>
<h2 align="center">Installer for AspectJ 8 Development Kit<sup><small>TM</small></sup></h2>

<p align="center">Version ${build.version.long} built on ${build.date}</p>
<p>This installs the complete AspectJ 6 Development Kit (AJDK) distribution, with
<p>This installs the complete AspectJ 8 Development Kit (AJDK) distribution, with
the compiler, aspect libraries, structure browser, ant tasks,
documentation, and examples.
This distribution is covered by the Eclipse Public License (see

+ 2
- 2
build/src/$installer$/org/aspectj/Main.java View File

@@ -998,9 +998,9 @@ class LocationPane extends WizardPane implements ActionListener {
public String getDefaultLocation() {
if (context.onWindows()) {
//XXX hard-coded majorminor version needs to be fixed by 1.1 release
return "c:\\aspectj1.7";
return "c:\\aspectj1.8";
} else {
return new File(System.getProperty("user.home"), "aspectj1.7").getAbsolutePath();
return new File(System.getProperty("user.home"), "aspectj1.8").getAbsolutePath();
}
}


+ 1
- 1
build/usedForMavenUpload/aspectjrt.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<packaging>jar</packaging>
<version>1.7.4.BUILD-SNAPSHOT</version>
<version>1.8.0.BUILD-SNAPSHOT</version>
<name>AspectJ runtime</name>
<description>The runtime needed to execute a program using AspectJ</description>
<url>http://www.aspectj.org</url>

+ 1
- 1
build/usedForMavenUpload/aspectjtools.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<packaging>jar</packaging>
<version>1.7.4.BUILD-SNAPSHOT</version>
<version>1.8.0.BUILD-SNAPSHOT</version>
<name>AspectJ tools</name>
<description>Tools from the AspectJ project</description>
<url>http://www.aspectj.org</url>

+ 1
- 1
build/usedForMavenUpload/aspectjweaver.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<packaging>jar</packaging>
<version>1.7.4.BUILD-SNAPSHOT</version>
<version>1.8.0.BUILD-SNAPSHOT</version>
<name>AspectJ weaver</name>
<description>The AspectJ weaver introduces advices to java classes</description>
<url>http://www.aspectj.org</url>

+ 1
- 1
build/usedForMavenUpload_milestone/aspectjrt.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<packaging>jar</packaging>
<version>1.7.0.M1</version>
<version>1.8.0.RC3</version>
<name>AspectJ runtime</name>
<description>The runtime needed to execute a program using AspectJ</description>
<url>http://www.aspectj.org</url>

+ 1
- 1
build/usedForMavenUpload_milestone/aspectjtools.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<packaging>jar</packaging>
<version>1.7.0.M1</version>
<version>1.8.0.RC3</version>
<name>AspectJ tools</name>
<description>Tools from the AspectJ project</description>
<url>http://www.aspectj.org</url>

+ 1
- 1
build/usedForMavenUpload_milestone/aspectjweaver.pom View File

@@ -5,7 +5,7 @@
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<packaging>jar</packaging>
<version>1.7.0.M1</version>
<version>1.8.0.RC3</version>
<name>AspectJ weaver</name>
<description>The AspectJ weaver introduces advices to java classes</description>
<url>http://www.aspectj.org</url>

+ 92
- 0
docs/dist/doc/README-180.html View File

@@ -0,0 +1,92 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html> <head>
<title>AspectJ 1.8.0 Readme</title>
<style type="text/css">
<!--
P { margin-left: 20px; }
PRE { margin-left: 20px; }
LI { margin-left: 20px; }
H4 { margin-left: 20px; }
H3 { margin-left: 10px; }
-->
</style>
</head>

<body>
<div align="right"><small>
&copy; Copyright 2014 Contributors.
All rights reserved.
</small></div>

<h1>AspectJ 1.8.0 Readme</h1>

<p>The full list of resolved issues in 1.8.0 is available
<a href="https://bugs.eclipse.org/bugs/buglist.cgi?query_format=advanced;bug_status=RESOLVED;bug_status=VERIFIED;bug_status=CLOSED;product=AspectJ;target_milestone=1.8.0.M1;target_milestone=1.8.0;">here</a></h2>.</p>

<ul>
<li>1.8.0 available 17-Apr-2014
<li>1.8.0.RC1 available 18-Mar-2014
<li>1.8.0.M1 available 29-Jul-2013
</ul>

<h2>Notable changes</h2>

<h3>Java 8 compilation</h3>

<p>AspectJ has been updated to the latest available Eclipse Java
compiler version that compiles Java8 code (the version available as a feature patch on top of Eclipse 4.3.2).</p>
</p>
<p>Here is a sample AspectJ8 program:</p>

<pre><code>
=== 8< ==== C.java ==== 8< ===
import java.util.Arrays;

interface I {
// Default method
default void foo() {
System.out.println("ABC");
}
}

public class C implements I{
public static void main(String[] args) {
new C().foo();
// Lambda
Runnable r = () -> { System.out.println("hello world!"); };
r.run();
// Used Java8 b97
Arrays.asList(MyClass.doSomething()).forEach((p) -> System.out.println(p));
}
}

aspect X {
before(): execution(* I.foo()) {
System.out.println("I.foo running");
}
before(): staticinitialization(!X) {
System.out.println("Clazz "+thisJoinPointStaticPart);
}
}


class Utils {
public static int compareByLength(String in, String out) {
return in.length() - out.length();
}
}

class MyClass {
public static String[] doSomething() {
String []args = new String[]{"4444","333","22","1"};
// Method reference
Arrays.sort(args,Utils::compareByLength);
return args;
}
}
=== 8< ==== C.java ==== 8< ===
</code></pre>

<!-- ============================== -->
</body>
</html>

+ 1
- 0
docs/dist/doc/index.html View File

@@ -138,6 +138,7 @@
<tr> <td>README's
</td>
<td>Changes and porting guide for AspectJ
<a href="README-180.html">1.8.0</a>,
<a href="README-174.html">1.7.4</a>,
<a href="README-173.html">1.7.3</a>,
<a href="README-172.html">1.7.2</a>,

+ 1
- 1
docs/install/intro.html View File

@@ -10,7 +10,7 @@

<body>

<h2 align="center">Installer for AspectJ(TM) 5 Development Kit</h2>
<h2 align="center">Installer for AspectJ(TM) 8 Development Kit</h2>

<p align="center">Version ${build.version.long} built on ${build.date}</p>
<p>${copyright.allRights.from1998}</p>

BIN
lib/asm/asm-5.0.1.jar View File


BIN
lib/asm/asm-5.0.1.renamed.jar View File


+ 3
- 3
lib/asm/build.xml View File

@@ -3,9 +3,9 @@
<!-- if you need this defining, use the jarjar-1.0.jar in this project -->
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask"/>

<target name="package" description="Jarjar asm-4.2.jar and prefix package name with aj">
<jarjar destfile="asm-4.2.renamed.jar">
<zipfileset src="asm-4.2.jar"/>
<target name="package" description="Jarjar asm-5.0.1.jar and prefix package name with aj">
<jarjar destfile="asm-5.0.1.renamed.jar">
<zipfileset src="asm-5.0.1.jar"/>
<rule pattern="org.objectweb.asm.**" result="aj.org.objectweb.asm.@1"/>
</jarjar>
</target>

BIN
lib/build/build.jar View File


+ 3
- 3
loadtime/src/org/aspectj/weaver/loadtime/ClassLoaderWeavingAdaptor.java View File

@@ -53,7 +53,7 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {

private boolean initialized;

private List m_dumpTypePattern = new ArrayList();
private List<TypePattern> m_dumpTypePattern = new ArrayList<TypePattern>();
private boolean m_dumpBefore = false;
private boolean dumpDirPerClassloader = false;

@@ -931,8 +931,8 @@ public class ClassLoaderWeavingAdaptor extends WeavingAdaptor {
// TODO AV - optimize for className.startWith only
ResolvedType classInfo = weaver.getWorld().resolve(UnresolvedType.forName(className), true);
// dump
for (Iterator iterator = m_dumpTypePattern.iterator(); iterator.hasNext();) {
TypePattern typePattern = (TypePattern) iterator.next();
for (Iterator<TypePattern> iterator = m_dumpTypePattern.iterator(); iterator.hasNext();) {
TypePattern typePattern = iterator.next();
if (typePattern.matchesStatically(classInfo)) {
// dump match
return true;

+ 3
- 3
loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java View File

@@ -366,11 +366,11 @@ public class ConcreteAspectCodeGen {
if (bytes != null) {
return bytes;
}
PerClause.Kind perclauseKind = PerClause.SINGLETON;
PerClause parentPerClause = (parent != null ? parent.getPerClause() : null);
if (parentPerClause == null) {
parentPerClause = new PerSingleton();
if (parentPerClause != null) {
perclauseKind = parentPerClause.getKind();
}
PerClause.Kind perclauseKind = PerClause.SINGLETON;
String perclauseString = null;

if (concreteAspect.perclause != null) {

+ 4
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java View File

@@ -692,11 +692,14 @@ public class BuildArgParser extends Main {
} else if (arg.equals("-1.7")) {
buildConfig.setBehaveInJava5Way(true);
unparsedArgs.add("-1.7");
} else if (arg.equals("-1.8")) {
buildConfig.setBehaveInJava5Way(true);
unparsedArgs.add("-1.8");
} else if (arg.equals("-source")) {
if (args.size() > nextArgIndex) {
String level = ((ConfigParser.Arg) 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("7") || level.equals("8") || level.equals("1.8")) {
buildConfig.setBehaveInJava5Way(true);
}
unparsedArgs.add("-source");

+ 5
- 4
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties View File

@@ -4,8 +4,8 @@
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.
### AspectJ-specific messages
compiler.name = AspectJ Compiler 1.7.5
compiler.version = Eclipse Compiler 0.B79_R37x, 3.7
compiler.name = AspectJ Compiler 1.8.0
compiler.version = Eclipse Compiler BETA_JAVA8_8661797, 3.9
compiler.copyright =

## this next one superceded by above...
@@ -63,8 +63,9 @@ Standard Eclipse compiler options:\n\
\ -1.5 -5 -5.0 use 1.5 compliance (-source 1.5 -target 1.5)\n\
\ -1.6 -6 -6.0 use 1.6 compliance (-source 1.6 -target 1.6)\n\
\ -1.7 -7 -7.0 use 1.7 compliance (-source 1.7 -target 1.7)\n\
\ -source <version> set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n\
\ -target <version> set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n\
\ -1.8 -8 -8.0 use 1.8 compliance (-source 1.8 -target 1.8)\n\
\ -source <version> set source level: 1.3 to 1.8 (or 5, 5.0, etc)\n\
\ -target <version> set classfile target: 1.1 to 1.8 (or 5, 5.0, etc)\n\
\ \n\
\ Warning options:\n\
\ -deprecation + deprecation outside deprecated code\n\

+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java View File

@@ -129,7 +129,7 @@ public class WeaverMessageHandler implements IMessageHandler {
if (details.length() != 0) {
problem.setSupplementaryMessageInfo(details.toString());
}
compiler.problemReporter.record(problem, problemSource, referenceContext);
compiler.problemReporter.record(problem, problemSource, referenceContext, message.isError());
return true;
}


+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java View File

@@ -74,7 +74,7 @@ public class AdviceDeclaration extends AjMethodDeclaration {

public AdviceDeclaration(CompilationResult result, AdviceKind kind) {
super(result);
this.returnType = TypeReference.baseTypeReference(T_void, 0);
this.returnType = TypeReference.baseTypeReference(T_void, 0,null);
this.kind = kind;
}


+ 6
- 4
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java View File

@@ -575,8 +575,8 @@ public class AspectDeclaration extends TypeDeclaration {

BranchLabel instanceFound = new BranchLabel(codeStream);

ExceptionLabel anythingGoesWrong = new ExceptionLabel(codeStream, world
.makeTypeBinding(UnresolvedType.JL_EXCEPTION));
TypeBinding exceptionTypeBinding = world.makeTypeBinding(UnresolvedType.JL_EXCEPTION);
ExceptionLabel anythingGoesWrong = new ExceptionLabel(codeStream, exceptionTypeBinding);
anythingGoesWrong.placeStart();
codeStream.aload_0();
codeStream.invoke(Opcodes.OPC_invokestatic,
@@ -604,7 +604,7 @@ public class AspectDeclaration extends TypeDeclaration {
codeStream.areturn();
anythingGoesWrong.placeEnd();
anythingGoesWrong.place();
codeStream.pushExceptionOnStack(exceptionTypeBinding); // For stackmap computation to behave
codeStream.astore_1();
codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION));

@@ -790,7 +790,8 @@ public class AspectDeclaration extends TypeDeclaration {
.makeTypeBinding(UnresolvedType.JL_CLASS), Modifier.PUBLIC, true);
codeStream.record(theTypeVar);
theTypeVar.recordInitializationStartPC(0);
ExceptionLabel exc = new ExceptionLabel(codeStream, world.makeTypeBinding(UnresolvedType.JL_EXCEPTION));
TypeBinding exceptionTypeBinding = world.makeTypeBinding(UnresolvedType.JL_EXCEPTION);
ExceptionLabel exc = new ExceptionLabel(codeStream, exceptionTypeBinding);
exc.placeStart();
codeStream.aload_0();
codeStream.ldc(NameMangler.perTypeWithinLocalAspectOf(typeX));
@@ -830,6 +831,7 @@ public class AspectDeclaration extends TypeDeclaration {
exc.placeEnd();
codeStream.areturn();
exc.place();
codeStream.pushExceptionOnStack(exceptionTypeBinding); // For stackmap computation to behave
codeStream.astore_1();
// this just returns null now - the old version used to throw the caught exception!
codeStream.aconst_null();

+ 4
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareAnnotationDeclaration.java View File

@@ -17,6 +17,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
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;
@@ -41,8 +42,9 @@ public class DeclareAnnotationDeclaration extends DeclareDeclaration {
symbolicDeclare.setAnnotationLocation(annotation.sourceStart, annotation.sourceEnd);
}

public void analyseCode(ClassScope classScope, InitializationFlowContext initializationContext, FlowInfo flowInfo) {
super.analyseCode(classScope, initializationContext, flowInfo);
@Override
public void analyseCode(ClassScope classScope, FlowContext flowContext, FlowInfo flowInfo) {
super.analyseCode(classScope, flowContext, flowInfo);

if (isRemover) {
if (((DeclareAnnotation) declareDecl).getKind() != DeclareAnnotation.AT_FIELD) {

+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java View File

@@ -55,7 +55,7 @@ public class DeclareDeclaration extends AjMethodDeclaration {
declarationSourceEnd = sourceEnd = declareDecl.getEnd();
}
// ??? we might need to set parameters to be empty
this.returnType = TypeReference.baseTypeReference(T_void, 0);
this.returnType = TypeReference.baseTypeReference(T_void, 0, null);
}

public void addAtAspectJAnnotations() {

+ 9
- 2
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java View File

@@ -27,6 +27,7 @@ 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;
@@ -77,11 +78,17 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
return (declaredModifiers & ClassFileConstants.AccFinal) != 0;
}

public void analyseCode(ClassScope currentScope, InitializationFlowContext flowContext, FlowInfo flowInfo) {
// public boolean isAbstract() {
// boolean b = (declaredModifiers & ClassFileConstants.AccAbstract) != 0;
// return b;//super.isAbstract();
// }

@Override
public void analyseCode(ClassScope classScope, FlowContext flowContext, FlowInfo flowInfo) {
if (Modifier.isAbstract(declaredModifiers))
return;

super.analyseCode(currentScope, flowContext, flowInfo);
super.analyseCode(classScope, flowContext, flowInfo);
}

public void resolve(ClassScope upperScope) {

+ 2
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/IntertypeMemberClassDeclaration.java View File

@@ -18,6 +18,7 @@ import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseSourceLocation;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseTypeMunger;
import org.aspectj.ajdt.internal.compiler.lookup.InterTypeScope;
import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
@@ -272,6 +273,6 @@ public class IntertypeMemberClassDeclaration extends TypeDeclaration {
}

public char[] alternativeName() {
return onType.getLastToken();
return CharOperation.concatWith(onType.getTypeName(),'.');//onType.getLastToken();
}
}

+ 1
- 1
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java View File

@@ -60,7 +60,7 @@ public class PointcutDeclaration extends AjMethodDeclaration {

public PointcutDeclaration(CompilationResult compilationResult) {
super(compilationResult);
this.returnType = TypeReference.baseTypeReference(T_void, 0);
this.returnType = TypeReference.baseTypeReference(T_void, 0, null);
}

private Pointcut getPointcut() {

+ 4
- 3
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/Proceed.java View File

@@ -1,6 +1,6 @@
/* *******************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* 2004 contributors
* Copyright (c) 2002-2014 Palo Alto Research Center, Incorporated (PARC)
* and Contributors
* All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
@@ -169,7 +169,8 @@ public class Proceed extends MessageSend {
}
checkInvocationArguments(scope,null,this.actualReceiverType,binding,
this.arguments,binding.parameters,argsContainCast,this);

this.resolvedType = binding.returnType;
return binding.returnType;
}


+ 16
- 3
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java View File

@@ -21,6 +21,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.DeclareAnnotationDeclaration;
import org.aspectj.ajdt.internal.compiler.ast.PointcutDeclaration;
@@ -48,6 +49,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.IPrivilegedHandler;
import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding;
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.ReferenceBinding;
@@ -506,6 +508,17 @@ public class AjProblemReporter extends ProblemReporter {
}
super.unusedPrivateType(typeDecl);
}
private final static char[] thisJoinPointName = "thisJoinPoint".toCharArray();
public void uninitializedLocalVariable(LocalVariableBinding binding, ASTNode location) {
if (CharOperation.equals(binding.name,thisJoinPointName)) {
// If in advice, this is not a problem
if (binding.declaringScope!=null && binding.declaringScope.referenceContext() instanceof AdviceDeclaration) {
return;
}
}
super.uninitializedLocalVariable(binding, location);
}
public void abstractMethodInConcreteClass(SourceTypeBinding type) {
if (type.scope!=null && type.scope.referenceContext instanceof AspectDeclaration) {
@@ -737,19 +750,19 @@ public class AjProblemReporter extends ProblemReporter {
}
}

public void duplicateMethodInType(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) {
public void duplicateMethodInType(AbstractMethodDeclaration methodDecl, boolean equalParameters, int severity) {
if (new String(methodDecl.selector).startsWith("ajc$interMethod")) {
// this is an ITD clash and will be reported in another way by AspectJ (173602)
return;
}
super.duplicateMethodInType(type, methodDecl, equalParameters, severity);
super.duplicateMethodInType(methodDecl, equalParameters, severity);
}

// pr246393 - if we are going to complain about privileged, we clearly don't know what is going on, so don't
// confuse the user
public void parseErrorInsertAfterToken(int start, int end, int currentKind, char[] errorTokenSource, String errorTokenName,
String expectedToken) {
if (expectedToken.equals("privileged")) {
if (expectedToken.equals("privileged") || expectedToken.equals("around")) {
super.parseErrorNoSuggestion(start, end, currentKind, errorTokenSource, errorTokenName);
} else {
super.parseErrorInsertAfterToken(start, end, currentKind, errorTokenSource, errorTokenName, expectedToken);

+ 10
- 10
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java View File

@@ -52,15 +52,15 @@ public class AjCompilerOptions extends CompilerOptions {


// constants for irritant levels
public static final int InvalidAbsoluteTypeName = IrritantSet.GROUP2 | ASTNode.Bit8;
public static final int InvalidWildCardTypeName = IrritantSet.GROUP2 | ASTNode.Bit9;
public static final int UnresolvableMember = IrritantSet.GROUP2 | ASTNode.Bit10;
public static final int TypeNotExposedToWeaver = IrritantSet.GROUP2 | ASTNode.Bit11;
public static final int ShadowNotInStructure = IrritantSet.GROUP2 | ASTNode.Bit12;
public static final int UnmatchedSuperTypeInCall = IrritantSet.GROUP2 | ASTNode.Bit13;
public static final int CannotImplementLazyTJP = IrritantSet.GROUP2 | ASTNode.Bit14;
public static final int NeedSerialVersionUIDField = IrritantSet.GROUP2 | ASTNode.Bit15;
public static final int IncompatibleSerialVersion = IrritantSet.GROUP2 | ASTNode.Bit16;
public static final int InvalidAbsoluteTypeName = IrritantSet.GROUP2 | ASTNode.Bit20;
public static final int InvalidWildCardTypeName = IrritantSet.GROUP2 | ASTNode.Bit21;
public static final int UnresolvableMember = IrritantSet.GROUP2 | ASTNode.Bit22;
public static final int TypeNotExposedToWeaver = IrritantSet.GROUP2 | ASTNode.Bit23;
public static final int ShadowNotInStructure = IrritantSet.GROUP2 | ASTNode.Bit24;
public static final int UnmatchedSuperTypeInCall = IrritantSet.GROUP2 | ASTNode.Bit25;
public static final int CannotImplementLazyTJP = IrritantSet.GROUP2 | ASTNode.Bit26;
public static final int NeedSerialVersionUIDField = IrritantSet.GROUP2 | ASTNode.Bit27;
public static final int IncompatibleSerialVersion = IrritantSet.GROUP2 | ASTNode.Bit28;

public boolean terminateAfterCompilation = false;
public boolean xSerializableAspects = false;
@@ -129,7 +129,7 @@ public class AjCompilerOptions extends CompilerOptions {
* @see org.eclipse.jdt.internal.compiler.impl.CompilerOptions#getMap()
*/
public Map getMap() {
Map map = super.getMap();
Map<String,String> map = super.getMap();
// now add AspectJ additional options
map.put(OPTION_ReportInvalidAbsoluteTypeName, getSeverityString(InvalidAbsoluteTypeName));
map.put(OPTION_ReportInvalidWildcardTypeName, getSeverityString(InvalidWildCardTypeName));

+ 7
- 0
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/CompactTypeStructureRepresentation.java View File

@@ -18,6 +18,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryField;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryNestedType;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryType;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.IBinaryTypeAnnotation;

/**
* Used to determine if a type has structurally changed during incremental compilation. At the end of compilation we create one of
@@ -54,6 +55,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType {
IBinaryMethod[] binMethods;
IBinaryNestedType[] memberTypes;
IBinaryAnnotation[] annotations;
IBinaryTypeAnnotation[] typeAnnotations;

public CompactTypeStructureRepresentation(ClassFileReader cfr, boolean isAspect) {
@@ -82,6 +84,7 @@ public class CompactTypeStructureRepresentation implements IBinaryType {
// references and which were real declarations
this.memberTypes = cfr.getMemberTypes(isAspect);
this.annotations = cfr.getAnnotations();
this.typeAnnotations = cfr.getTypeAnnotations();
this.sourceName = cfr.getSourceName();
this.className = cfr.getName(); // slashes...
this.modifiers = cfr.getModifiers();
@@ -174,4 +177,8 @@ public class CompactTypeStructureRepresentation implements IBinaryType {
return sourceName;
}

public IBinaryTypeAnnotation[] getTypeAnnotations() {
return typeAnnotations;
}

}

+ 29
- 20
org.aspectj.ajdt.core/src/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java View File

@@ -2189,7 +2189,7 @@ public class AjASTConverter extends ASTConverter {
if (this.resolveBindings) {
recordNodes(classInstanceCreation, allocation);
}
removeTrailingCommentFromExpressionEndingWithAParen(classInstanceCreation);
// removeTrailingCommentFromExpressionEndingWithAParen(classInstanceCreation);
return classInstanceCreation;
}
}
@@ -2868,7 +2868,7 @@ public class AjASTConverter extends ASTConverter {
length = typeReference.sourceEnd - typeReference.sourceStart + 1;
// need to find out if this is an array type of primitive types or not
if (isPrimitiveType(name)) {
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length)[1];
if (end == -1) {
end = sourceStart + length - 1;
}
@@ -2880,7 +2880,7 @@ public class AjASTConverter extends ASTConverter {
ParameterizedSingleTypeReference parameterizedSingleTypeReference = (ParameterizedSingleTypeReference) typeReference;
final SimpleName simpleName = new SimpleName(this.ast);
simpleName.internalSetIdentifier(new String(name));
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length)[1];
if (end == -1) {
end = sourceStart + length - 1;
}
@@ -2926,7 +2926,7 @@ public class AjASTConverter extends ASTConverter {
simpleName.internalSetIdentifier(new String(name));
// we need to search for the starting position of the first brace in order to set the proper length
// PR http://dev.eclipse.org/bugs/show_bug.cgi?id=10759
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length);
int end = retrieveEndOfElementTypeNamePosition(sourceStart, sourceStart + length)[1];
if (end == -1) {
end = sourceStart + length - 1;
}
@@ -3620,32 +3620,41 @@ public class AjASTConverter extends ASTConverter {
}

/**
* This method is used to retrieve the position just before the left bracket.
* This method is used to retrieve the start and end position of a name or primitive type token.
*
* @return int the dimension found, -1 if none
* @return int[] a single dimensional array, with two elements, for the start and end positions of the name respectively
*/
protected int retrieveEndOfElementTypeNamePosition(int start, int end) {
protected int[] retrieveEndOfElementTypeNamePosition(int start, int end) {
this.scanner.resetTo(start, end);
boolean isAnnotation = false;
try {
int token;
while ((token = this.scanner.getNextToken()) != TerminalTokens.TokenNameEOF) {
switch (token) {
case TerminalTokens.TokenNameIdentifier:
case TerminalTokens.TokenNamebyte:
case TerminalTokens.TokenNamechar:
case TerminalTokens.TokenNamedouble:
case TerminalTokens.TokenNamefloat:
case TerminalTokens.TokenNameint:
case TerminalTokens.TokenNamelong:
case TerminalTokens.TokenNameshort:
case TerminalTokens.TokenNameboolean:
return this.scanner.currentPosition - 1;
switch(token) {
case TerminalTokens.TokenNameAT:
isAnnotation = true;
break;
case TerminalTokens.TokenNameIdentifier:
if (isAnnotation) {
isAnnotation = false;
break;
}
//$FALL-THROUGH$
case TerminalTokens.TokenNamebyte:
case TerminalTokens.TokenNamechar:
case TerminalTokens.TokenNamedouble:
case TerminalTokens.TokenNamefloat:
case TerminalTokens.TokenNameint:
case TerminalTokens.TokenNamelong:
case TerminalTokens.TokenNameshort:
case TerminalTokens.TokenNameboolean:
return new int[]{this.scanner.startPosition, this.scanner.currentPosition - 1};
}
}
} catch (InvalidInputException e) {
} catch(InvalidInputException e) {
// ignore
}
return -1;
return new int[]{-1, -1};
}

/**

+ 4
- 0
org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java View File

@@ -55,6 +55,10 @@ public class AsmBuilderTest extends TestCase {
public char[] getFileName() {
return null;
}

public boolean ignoreOptionalProblems() {
return false;
}
};
TypeDeclaration local = new TypeDeclaration(new CompilationResult(cu, 0, 0, 0));

+ 239
- 137
org.aspectj.matcher/src/org/aspectj/weaver/ReferenceType.java View File

@@ -24,27 +24,35 @@ import org.aspectj.weaver.patterns.Declare;
import org.aspectj.weaver.patterns.PerClause;

/**
* A reference type represents some 'real' type, not a primitive, not an array - but a real type, for example java.util.List. Each
* ReferenceType has a delegate that is the underlying artifact - either an eclipse artifact or a bcel artifact. If the type
* represents a raw type (i.e. there is a generic form) then the genericType field is set to point to the generic type. If it is for
* a parameterized type then the generic type is also set to point to the generic form.
* A reference type represents some 'real' type, not a primitive, not an array -
* but a real type, for example java.util.List. Each ReferenceType has a
* delegate that is the underlying artifact - either an eclipse artifact or a
* bcel artifact. If the type represents a raw type (i.e. there is a generic
* form) then the genericType field is set to point to the generic type. If it
* is for a parameterized type then the generic type is also set to point to the
* generic form.
*/
public class ReferenceType extends ResolvedType {

public static final ReferenceType[] EMPTY_ARRAY = new ReferenceType[0];

/**
* For generic types, this list holds references to all the derived raw and parameterized versions. We need this so that if the
* generic delegate is swapped during incremental compilation, the delegate of the derivatives is swapped also.
* For generic types, this list holds references to all the derived raw and
* parameterized versions. We need this so that if the generic delegate is
* swapped during incremental compilation, the delegate of the derivatives
* is swapped also.
*/
private final List<WeakReference<ReferenceType>> derivativeTypes = new ArrayList<WeakReference<ReferenceType>>();

/**
* For parameterized types (or the raw type) - this field points to the actual reference type from which they are derived.
* For parameterized types (or the raw type) - this field points to the
* actual reference type from which they are derived.
*/
ReferenceType genericType = null;
ReferenceType rawType = null; // generic types have a pointer back to their raw variant (prevents GC of the raw from the typemap!)

ReferenceType rawType = null; // generic types have a pointer back to their
// raw variant (prevents GC of the raw from
// the typemap!)

ReferenceTypeDelegate delegate = null;
int startPos = 0;
@@ -54,18 +62,23 @@ public class ReferenceType extends ResolvedType {
ResolvedMember[] parameterizedMethods = null;
ResolvedMember[] parameterizedFields = null;
ResolvedMember[] parameterizedPointcuts = null;
WeakReference<ResolvedType[]> parameterizedInterfaces = new WeakReference<ResolvedType[]>(null);
WeakReference<ResolvedType[]> parameterizedInterfaces = new WeakReference<ResolvedType[]>(
null);
Collection<Declare> parameterizedDeclares = null;
// Collection parameterizedTypeMungers = null;

// During matching it can be necessary to temporary mark types as annotated. For example
// a declare @type may trigger a separate declare parents to match, and so the annotation
// is temporarily held against the referencetype, the annotation will be properly
// During matching it can be necessary to temporary mark types as annotated.
// For example
// a declare @type may trigger a separate declare parents to match, and so
// the annotation
// is temporarily held against the referencetype, the annotation will be
// properly
// added to the class during weaving.
private ResolvedType[] annotationTypes = null;
private AnnotationAJ[] annotations = null;

// Similarly these are temporary replacements and additions for the superclass and
// Similarly these are temporary replacements and additions for the
// superclass and
// superinterfaces
private ResolvedType newSuperclass;
private ResolvedType[] newInterfaces;
@@ -87,8 +100,10 @@ public class ReferenceType extends ResolvedType {
/**
* Constructor used when creating a parameterized type.
*/
public ReferenceType(ResolvedType theGenericType, ResolvedType[] theParameters, World aWorld) {
super(makeParameterizedSignature(theGenericType, theParameters), theGenericType.signatureErasure, aWorld);
public ReferenceType(ResolvedType theGenericType,
ResolvedType[] theParameters, World aWorld) {
super(makeParameterizedSignature(theGenericType, theParameters),
theGenericType.signatureErasure, aWorld);
ReferenceType genericReferenceType = (ReferenceType) theGenericType;
this.typeParameters = theParameters;
this.genericType = genericReferenceType;
@@ -98,40 +113,43 @@ public class ReferenceType extends ResolvedType {
}

synchronized void addDependentType(ReferenceType dependent) {
// checkDuplicates(dependent);
// checkDuplicates(dependent);
synchronized (derivativeTypes) {
this.derivativeTypes.add(new WeakReference<ReferenceType>(dependent));
this.derivativeTypes
.add(new WeakReference<ReferenceType>(dependent));
}
}
public void checkDuplicates(ReferenceType newRt) {
synchronized (derivativeTypes) {
List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
for (WeakReference<ReferenceType> derivativeTypeReference: derivativeTypes) {
ReferenceType derivativeType = derivativeTypeReference.get();
if (derivativeType==null) {
forRemoval.add(derivativeTypeReference);
} else {
if (derivativeType.getTypekind()!=newRt.getTypekind()) {
continue; // cannot be this one
}
if (equal2(newRt.getTypeParameters(),derivativeType.getTypeParameters())) {
if (TypeMap.useExpendableMap) {
throw new IllegalStateException();
}
}
}
}
derivativeTypes.removeAll(forRemoval);
}
}
private boolean equal2(UnresolvedType[] typeParameters, UnresolvedType[] resolvedParameters) {
if (typeParameters.length!=resolvedParameters.length) {
List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
for (WeakReference<ReferenceType> derivativeTypeReference : derivativeTypes) {
ReferenceType derivativeType = derivativeTypeReference.get();
if (derivativeType == null) {
forRemoval.add(derivativeTypeReference);
} else {
if (derivativeType.getTypekind() != newRt.getTypekind()) {
continue; // cannot be this one
}
if (equal2(newRt.getTypeParameters(),
derivativeType.getTypeParameters())) {
if (TypeMap.useExpendableMap) {
throw new IllegalStateException();
}
}
}
}
derivativeTypes.removeAll(forRemoval);
}
}

private boolean equal2(UnresolvedType[] typeParameters,
UnresolvedType[] resolvedParameters) {
if (typeParameters.length != resolvedParameters.length) {
return false;
}
int len = typeParameters.length;
for (int p=0;p<len;p++) {
for (int p = 0; p < len; p++) {
if (!typeParameters[p].equals(resolvedParameters[p])) {
return false;
}
@@ -153,7 +171,7 @@ public class ReferenceType extends ResolvedType {
public ReferenceType(UnresolvedType genericType, World world) {
super(genericType.getSignature(), world);
typeKind = TypeKind.GENERIC;
this.typeVariables=genericType.typeVariables;
this.typeVariables = genericType.typeVariables;
}

@Override
@@ -168,7 +186,8 @@ public class ReferenceType extends ResolvedType {

@Override
public boolean isGenericType() {
return !isParameterizedType() && !isRawType() && getDelegate().isGeneric();
return !isParameterizedType() && !isRawType()
&& getDelegate().isGeneric();
}

public String getGenericSignature() {
@@ -184,10 +203,11 @@ public class ReferenceType extends ResolvedType {
@Override
public void addAnnotation(AnnotationAJ annotationX) {
if (annotations == null) {
annotations = new AnnotationAJ[]{annotationX};
annotations = new AnnotationAJ[] { annotationX };
} else {
AnnotationAJ[] newAnnotations = new AnnotationAJ[annotations.length + 1];
System.arraycopy(annotations, 0, newAnnotations, 1, annotations.length);
System.arraycopy(annotations, 0, newAnnotations, 1,
annotations.length);
newAnnotations[0] = annotationX;
annotations = newAnnotations;
}
@@ -215,7 +235,8 @@ public class ReferenceType extends ResolvedType {
annotationTypes[0] = ofType;
} else {
ResolvedType[] newAnnotationTypes = new ResolvedType[annotationTypes.length + 1];
System.arraycopy(annotationTypes, 0, newAnnotationTypes, 1, annotationTypes.length);
System.arraycopy(annotationTypes, 0, newAnnotationTypes, 1,
annotationTypes.length);
newAnnotationTypes[0] = ofType;
annotationTypes = newAnnotationTypes;
}
@@ -224,16 +245,21 @@ public class ReferenceType extends ResolvedType {
@Override
public ResolvedType[] getAnnotationTypes() {
if (getDelegate() == null) {
throw new BCException("Unexpected null delegate for type " + this.getName());
throw new BCException("Unexpected null delegate for type "
+ this.getName());
}
if (annotationTypes == null) {
// there are no extras:
return getDelegate().getAnnotationTypes();
} else {
ResolvedType[] delegateAnnotationTypes = getDelegate().getAnnotationTypes();
ResolvedType[] result = new ResolvedType[annotationTypes.length + delegateAnnotationTypes.length];
System.arraycopy(delegateAnnotationTypes, 0, result, 0, delegateAnnotationTypes.length);
System.arraycopy(annotationTypes, 0, result, delegateAnnotationTypes.length, annotationTypes.length);
ResolvedType[] delegateAnnotationTypes = getDelegate()
.getAnnotationTypes();
ResolvedType[] result = new ResolvedType[annotationTypes.length
+ delegateAnnotationTypes.length];
System.arraycopy(delegateAnnotationTypes, 0, result, 0,
delegateAnnotationTypes.length);
System.arraycopy(annotationTypes, 0, result,
delegateAnnotationTypes.length, annotationTypes.length);
return result;
}
}
@@ -331,7 +357,8 @@ public class ReferenceType extends ResolvedType {
}

if (this.isParameterizedType() && other.isRawType()) {
return ((ReferenceType) this.getRawType()).isCoerceableFrom(other.getGenericType());
return ((ReferenceType) this.getRawType()).isCoerceableFrom(other
.getGenericType());
}

if (this.isRawType() && other.isParameterizedType()) {
@@ -364,28 +391,33 @@ public class ReferenceType extends ResolvedType {
}
ResolvedType myRawType = getRawType();
ResolvedType theirRawType = other.getRawType();
if (myRawType == theirRawType || myRawType.isCoerceableFrom(theirRawType)) {
if (myRawType == theirRawType
|| myRawType.isCoerceableFrom(theirRawType)) {
if (getTypeParameters().length == other.getTypeParameters().length) {
// there's a chance it can be done
ResolvedType[] myTypeParameters = getResolvedTypeParameters();
ResolvedType[] theirTypeParameters = other.getResolvedTypeParameters();
ResolvedType[] theirTypeParameters = other
.getResolvedTypeParameters();
for (int i = 0; i < myTypeParameters.length; i++) {
if (myTypeParameters[i] != theirTypeParameters[i]) {
// thin ice now... but List<String> may still be
// coerceable from e.g. List<T>
if (myTypeParameters[i].isGenericWildcard()) {
BoundedReferenceType wildcard = (BoundedReferenceType) myTypeParameters[i];
if (!wildcard.canBeCoercedTo(theirTypeParameters[i])) {
if (!wildcard
.canBeCoercedTo(theirTypeParameters[i])) {
return false;
}
} else if (myTypeParameters[i].isTypeVariableReference()) {
} else if (myTypeParameters[i]
.isTypeVariableReference()) {
TypeVariableReferenceType tvrt = (TypeVariableReferenceType) myTypeParameters[i];
TypeVariable tv = tvrt.getTypeVariable();
tv.resolve(world);
if (!tv.canBeBoundTo(theirTypeParameters[i])) {
return false;
}
} else if (theirTypeParameters[i].isTypeVariableReference()) {
} else if (theirTypeParameters[i]
.isTypeVariableReference()) {
TypeVariableReferenceType tvrt = (TypeVariableReferenceType) theirTypeParameters[i];
TypeVariable tv = tvrt.getTypeVariable();
tv.resolve(world);
@@ -431,7 +463,8 @@ public class ReferenceType extends ResolvedType {
if (!world.isInJava5Mode()) {
return false;
}
if (ResolvedType.validBoxing.contains(this.getSignature() + other.getSignature())) {
if (ResolvedType.validBoxing.contains(this.getSignature()
+ other.getSignature())) {
return true;
}
}
@@ -443,7 +476,8 @@ public class ReferenceType extends ResolvedType {
return true;
}

if (!isTypeVariableReference() && other.getSignature().equals("Ljava/lang/Object;")) {
if (!isTypeVariableReference()
&& other.getSignature().equals("Ljava/lang/Object;")) {
return false;
}

@@ -476,28 +510,38 @@ public class ReferenceType extends ResolvedType {
return true;
}
// we have to match by parameters one at a time
ResolvedType[] theirParameters = other.getResolvedTypeParameters();
ResolvedType[] theirParameters = other
.getResolvedTypeParameters();
boolean parametersAssignable = true;
if (myParameters.length == theirParameters.length) {
for (int i = 0; i < myParameters.length && parametersAssignable; i++) {
for (int i = 0; i < myParameters.length
&& parametersAssignable; i++) {
if (myParameters[i] == theirParameters[i]) {
continue;
}
// dont do this: pr253109
// if (myParameters[i].isAssignableFrom(theirParameters[i], allowMissing)) {
// if
// (myParameters[i].isAssignableFrom(theirParameters[i],
// allowMissing)) {
// continue;
// }
ResolvedType mp = myParameters[i];
ResolvedType tp = theirParameters[i];
if (mp.isParameterizedType() && tp.isParameterizedType()) {
if (mp.isParameterizedType()
&& tp.isParameterizedType()) {
if (mp.getGenericType().equals(tp.getGenericType())) {
UnresolvedType[] mtps = mp.getTypeParameters();
UnresolvedType[] ttps = tp.getTypeParameters();
for (int ii = 0; ii < mtps.length; ii++) {
if (mtps[ii].isTypeVariableReference() && ttps[ii].isTypeVariableReference()) {
TypeVariable mtv = ((TypeVariableReferenceType) mtps[ii]).getTypeVariable();
boolean b = mtv.canBeBoundTo((ResolvedType) ttps[ii]);
if (!b) {// TODO incomplete testing here I think
if (mtps[ii].isTypeVariableReference()
&& ttps[ii]
.isTypeVariableReference()) {
TypeVariable mtv = ((TypeVariableReferenceType) mtps[ii])
.getTypeVariable();
boolean b = mtv
.canBeBoundTo((ResolvedType) ttps[ii]);
if (!b) {// TODO incomplete testing here
// I think
parametersAssignable = false;
break;
}
@@ -512,9 +556,13 @@ public class ReferenceType extends ResolvedType {
break;
}
}
if (myParameters[i].isTypeVariableReference() && theirParameters[i].isTypeVariableReference()) {
TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i]).getTypeVariable();
// TypeVariable theirTV = ((TypeVariableReferenceType) theirParameters[i]).getTypeVariable();
if (myParameters[i].isTypeVariableReference()
&& theirParameters[i].isTypeVariableReference()) {
TypeVariable myTV = ((TypeVariableReferenceType) myParameters[i])
.getTypeVariable();
// TypeVariable theirTV =
// ((TypeVariableReferenceType)
// theirParameters[i]).getTypeVariable();
boolean b = myTV.canBeBoundTo(theirParameters[i]);
if (!b) {// TODO incomplete testing here I think
parametersAssignable = false;
@@ -545,21 +593,27 @@ public class ReferenceType extends ResolvedType {

// eg this=T other=Ljava/lang/Object;
if (isTypeVariableReference() && !other.isTypeVariableReference()) {
TypeVariable aVar = ((TypeVariableReference) this).getTypeVariable();
TypeVariable aVar = ((TypeVariableReference) this)
.getTypeVariable();
return aVar.resolve(world).canBeBoundTo(other);
}

if (other.isTypeVariableReference()) {
TypeVariableReferenceType otherType = (TypeVariableReferenceType) other;
if (this instanceof TypeVariableReference) {
return ((TypeVariableReference) this).getTypeVariable().resolve(world)
.canBeBoundTo(otherType.getTypeVariable().getFirstBound().resolve(world));// pr171952
return ((TypeVariableReference) this)
.getTypeVariable()
.resolve(world)
.canBeBoundTo(
otherType.getTypeVariable().getFirstBound()
.resolve(world));// pr171952
// return
// ((TypeVariableReference)this).getTypeVariable()==otherType
// .getTypeVariable();
} else {
// FIXME asc should this say canBeBoundTo??
return this.isAssignableFrom(otherType.getTypeVariable().getFirstBound().resolve(world));
return this.isAssignableFrom(otherType.getTypeVariable()
.getFirstBound().resolve(world));
}
}

@@ -624,7 +678,8 @@ public class ReferenceType extends ResolvedType {
ResolvedMember[] delegateFields = getDelegate().getDeclaredFields();
parameterizedFields = new ResolvedMember[delegateFields.length];
for (int i = 0; i < delegateFields.length; i++) {
parameterizedFields[i] = delegateFields[i].parameterizedWith(getTypesForMemberParameterization(), this,
parameterizedFields[i] = delegateFields[i].parameterizedWith(
getTypesForMemberParameterization(), this,
isParameterizedType());
}
return parameterizedFields;
@@ -634,8 +689,9 @@ public class ReferenceType extends ResolvedType {
}

/**
* Find out from the generic signature the true signature of any interfaces I implement. If I am parameterized, these may then
* need to be parameterized before returning.
* Find out from the generic signature the true signature of any interfaces
* I implement. If I am parameterized, these may then need to be
* parameterized before returning.
*/
@Override
public ResolvedType[] getDeclaredInterfaces() {
@@ -643,7 +699,8 @@ public class ReferenceType extends ResolvedType {
if (interfaces != null) {
return interfaces;
}
ResolvedType[] delegateInterfaces = getDelegate().getDeclaredInterfaces();
ResolvedType[] delegateInterfaces = getDelegate()
.getDeclaredInterfaces();
if (isRawType()) {
if (newInterfaces != null) {// debug 375777
throw new IllegalStateException(
@@ -652,17 +709,23 @@ public class ReferenceType extends ResolvedType {
}
ResolvedType[] newInterfacesFromGenericType = genericType.newInterfaces;
if (newInterfacesFromGenericType != null) {
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length + newInterfacesFromGenericType.length];
System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0, delegateInterfaces.length);
System.arraycopy(newInterfacesFromGenericType, 0, extraInterfaces, delegateInterfaces.length,
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
+ newInterfacesFromGenericType.length];
System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
delegateInterfaces.length);
System.arraycopy(newInterfacesFromGenericType, 0,
extraInterfaces, delegateInterfaces.length,
newInterfacesFromGenericType.length);
delegateInterfaces = extraInterfaces;
}
} else if (newInterfaces != null) {
// OPTIMIZE does this part of the method trigger often?
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length + newInterfaces.length];
System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0, delegateInterfaces.length);
System.arraycopy(newInterfaces, 0, extraInterfaces, delegateInterfaces.length, newInterfaces.length);
ResolvedType[] extraInterfaces = new ResolvedType[delegateInterfaces.length
+ newInterfaces.length];
System.arraycopy(delegateInterfaces, 0, extraInterfaces, 0,
delegateInterfaces.length);
System.arraycopy(newInterfaces, 0, extraInterfaces,
delegateInterfaces.length, newInterfaces.length);

delegateInterfaces = extraInterfaces;
}
@@ -676,12 +739,14 @@ public class ReferenceType extends ResolvedType {
// needs more or less than this type does. (pr124803/pr125080)

if (delegateInterfaces[i].isParameterizedType()) {
interfaces[i] = delegateInterfaces[i].parameterize(getMemberParameterizationMap()).resolve(world);
interfaces[i] = delegateInterfaces[i].parameterize(
getMemberParameterizationMap()).resolve(world);
} else {
interfaces[i] = delegateInterfaces[i];
}
}
parameterizedInterfaces = new WeakReference<ResolvedType[]>(interfaces);
parameterizedInterfaces = new WeakReference<ResolvedType[]>(
interfaces);
return interfaces;
} else if (isRawType()) {
UnresolvedType[] paramTypes = getTypesForMemberParameterization();
@@ -691,32 +756,41 @@ public class ReferenceType extends ResolvedType {
if (interfaces[i].isGenericType()) {
// a generic supertype of a raw type is replaced by its raw
// equivalent
interfaces[i] = interfaces[i].getRawType().resolve(getWorld());
interfaces[i] = interfaces[i].getRawType().resolve(
getWorld());
} else if (interfaces[i].isParameterizedType()) {
// a parameterized supertype collapses any type vars to
// their upper bounds
UnresolvedType[] toUseForParameterization = determineThoseTypesToUse(interfaces[i], paramTypes);
interfaces[i] = interfaces[i].parameterizedWith(toUseForParameterization);
UnresolvedType[] toUseForParameterization = determineThoseTypesToUse(
interfaces[i], paramTypes);
interfaces[i] = interfaces[i]
.parameterizedWith(toUseForParameterization);
}
}
parameterizedInterfaces = new WeakReference<ResolvedType[]>(interfaces);
parameterizedInterfaces = new WeakReference<ResolvedType[]>(
interfaces);
return interfaces;
}
if (getDelegate().isCacheable()) {
parameterizedInterfaces = new WeakReference<ResolvedType[]>(delegateInterfaces);
parameterizedInterfaces = new WeakReference<ResolvedType[]>(
delegateInterfaces);
}
return delegateInterfaces;
}

/**
* It is possible this type has multiple type variables but the interface we are about to parameterize only uses a subset - this
* method determines the subset to use by looking at the type variable names used. For example: <code>
* It is possible this type has multiple type variables but the interface we
* are about to parameterize only uses a subset - this method determines the
* subset to use by looking at the type variable names used. For example:
* <code>
* class Foo<T extends String,E extends Number> implements SuperInterface<T> {}
* </code> where <code>
* interface SuperInterface<Z> {}
* </code> In that example, a use of the 'Foo' raw type should know that it implements the SuperInterface<String>.
* </code> In that example, a use of the 'Foo' raw type should know that it
* implements the SuperInterface<String>.
*/
private UnresolvedType[] determineThoseTypesToUse(ResolvedType parameterizedInterface, UnresolvedType[] paramTypes) {
private UnresolvedType[] determineThoseTypesToUse(
ResolvedType parameterizedInterface, UnresolvedType[] paramTypes) {
// What are the type parameters for the supertype?
UnresolvedType[] tParms = parameterizedInterface.getTypeParameters();
UnresolvedType[] retVal = new UnresolvedType[tParms.length];
@@ -751,8 +825,9 @@ public class ReferenceType extends ResolvedType {
}

/**
* Returns the position within the set of type variables for this type for the specified type variable name. Returns -1 if there
* is no type variable with the specified name.
* Returns the position within the set of type variables for this type for
* the specified type variable name. Returns -1 if there is no type variable
* with the specified name.
*/
private int getRank(String tvname) {
TypeVariable[] thisTypesTVars = getGenericType().getTypeVariables();
@@ -771,11 +846,13 @@ public class ReferenceType extends ResolvedType {
return parameterizedMethods;
}
if (isParameterizedType() || isRawType()) {
ResolvedMember[] delegateMethods = getDelegate().getDeclaredMethods();
ResolvedMember[] delegateMethods = getDelegate()
.getDeclaredMethods();
UnresolvedType[] parameters = getTypesForMemberParameterization();
parameterizedMethods = new ResolvedMember[delegateMethods.length];
for (int i = 0; i < delegateMethods.length; i++) {
parameterizedMethods[i] = delegateMethods[i].parameterizedWith(parameters, this, isParameterizedType());
parameterizedMethods[i] = delegateMethods[i].parameterizedWith(
parameters, this, isParameterizedType());
}
return parameterizedMethods;
} else {
@@ -789,11 +866,13 @@ public class ReferenceType extends ResolvedType {
return parameterizedPointcuts;
}
if (isParameterizedType()) {
ResolvedMember[] delegatePointcuts = getDelegate().getDeclaredPointcuts();
ResolvedMember[] delegatePointcuts = getDelegate()
.getDeclaredPointcuts();
parameterizedPointcuts = new ResolvedMember[delegatePointcuts.length];
for (int i = 0; i < delegatePointcuts.length; i++) {
parameterizedPointcuts[i] = delegatePointcuts[i].parameterizedWith(getTypesForMemberParameterization(), this,
isParameterizedType());
parameterizedPointcuts[i] = delegatePointcuts[i]
.parameterizedWith(getTypesForMemberParameterization(),
this, isParameterizedType());
}
return parameterizedPointcuts;
} else {
@@ -830,9 +909,11 @@ public class ReferenceType extends ResolvedType {
@Override
public PerClause getPerClause() {
PerClause pclause = getDelegate().getPerClause();
if (pclause != null && isParameterizedType()) { // could cache the result here...
if (pclause != null && isParameterizedType()) { // could cache the
// result here...
Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
pclause = (PerClause) pclause.parameterizeWith(parameterizationMap, world);
pclause = (PerClause) pclause.parameterizeWith(parameterizationMap,
world);
}
return pclause;
}
@@ -848,7 +929,8 @@ public class ReferenceType extends ResolvedType {
parameterizedDeclares = new ArrayList<Declare>();
Map<String, UnresolvedType> parameterizationMap = getAjMemberParameterizationMap();
for (Declare declareStatement : genericDeclares) {
parameterizedDeclares.add(declareStatement.parameterizeWith(parameterizationMap, world));
parameterizedDeclares.add(declareStatement.parameterizeWith(
parameterizationMap, world));
}
declares = parameterizedDeclares;
} else {
@@ -875,7 +957,8 @@ public class ReferenceType extends ResolvedType {
return getDelegate().getModifiers();
}

WeakReference<ResolvedType> superclassReference = new WeakReference<ResolvedType>(null);
WeakReference<ResolvedType> superclassReference = new WeakReference<ResolvedType>(
null);

@Override
public ResolvedType getSuperclass() {
@@ -884,8 +967,10 @@ public class ReferenceType extends ResolvedType {
// return ret;
// }
if (newSuperclass != null) {
if (this.isParameterizedType() && newSuperclass.isParameterizedType()) {
return newSuperclass.parameterize(getMemberParameterizationMap()).resolve(getWorld());
if (this.isParameterizedType()
&& newSuperclass.isParameterizedType()) {
return newSuperclass.parameterize(
getMemberParameterizationMap()).resolve(getWorld());
}
if (getDelegate().isCacheable()) {
superclassReference = new WeakReference<ResolvedType>(ret);
@@ -899,7 +984,8 @@ public class ReferenceType extends ResolvedType {
world.setTypeVariableLookupScope(null);
}
if (this.isParameterizedType() && ret.isParameterizedType()) {
ret = ret.parameterize(getMemberParameterizationMap()).resolve(getWorld());
ret = ret.parameterize(getMemberParameterizationMap()).resolve(
getWorld());
}
if (getDelegate().isCacheable()) {
superclassReference = new WeakReference<ResolvedType>(ret);
@@ -914,16 +1000,18 @@ public class ReferenceType extends ResolvedType {
public void setDelegate(ReferenceTypeDelegate delegate) {
// Don't copy from BcelObjectType to EclipseSourceType - the context may
// be tidied (result null'd) after previous weaving
if (this.delegate != null && this.delegate.copySourceContext()
if (this.delegate != null
&& this.delegate.copySourceContext()
&& this.delegate.getSourceContext() != SourceContextImpl.UNKNOWN_SOURCE_CONTEXT) {
((AbstractReferenceTypeDelegate) delegate).setSourceContext(this.delegate.getSourceContext());
((AbstractReferenceTypeDelegate) delegate)
.setSourceContext(this.delegate.getSourceContext());
}
this.delegate = delegate;
synchronized (derivativeTypes) {
List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
for (WeakReference<ReferenceType> derivativeRef : derivativeTypes) {
ReferenceType derivative = derivativeRef.get();
if (derivative!=null) {
if (derivative != null) {
derivative.setDelegate(delegate);
} else {
forRemoval.add(derivativeRef);
@@ -997,8 +1085,9 @@ public class ReferenceType extends ResolvedType {
genericType.rawType = this;
}
if (this.isRawType() && rt.isRawType()) {
new RuntimeException("PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: "
+ this.getName()).printStackTrace();
new RuntimeException(
"PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: "
+ this.getName()).printStackTrace();
}
}

@@ -1017,13 +1106,15 @@ public class ReferenceType extends ResolvedType {
}

/**
* a parameterized signature starts with a "P" in place of the "L", see the comment on signatures in UnresolvedType.
* a parameterized signature starts with a "P" in place of the "L", see the
* comment on signatures in UnresolvedType.
*
* @param aGenericType
* @param someParameters
* @return
*/
private static String makeParameterizedSignature(ResolvedType aGenericType, ResolvedType[] someParameters) {
private static String makeParameterizedSignature(ResolvedType aGenericType,
ResolvedType[] someParameters) {
String rawSignature = aGenericType.getErasureSignature();
StringBuffer ret = new StringBuffer();
ret.append(PARAMETERIZED_TYPE_IDENTIFIER);
@@ -1036,19 +1127,24 @@ public class ReferenceType extends ResolvedType {
return ret.toString();
}

private static String makeDeclaredSignature(ResolvedType aGenericType, UnresolvedType[] someParameters) {
private static String makeDeclaredSignature(ResolvedType aGenericType,
UnresolvedType[] someParameters) {
StringBuffer ret = new StringBuffer();
String rawSig = aGenericType.getErasureSignature();
ret.append(rawSig.substring(0, rawSig.length() - 1));
ret.append("<");
for (int i = 0; i < someParameters.length; i++) {
if (someParameters[i] instanceof ReferenceType) {
ret.append(((ReferenceType)someParameters[i]).getSignatureForAttribute());
ret.append(((ReferenceType) someParameters[i])
.getSignatureForAttribute());
} else if (someParameters[i] instanceof Primitive) {
ret.append(((Primitive)someParameters[i]).getSignatureForAttribute());
ret.append(((Primitive) someParameters[i])
.getSignatureForAttribute());
} else {
throw new IllegalStateException("DebugFor325731: expected a ReferenceType or Primitive but was " + someParameters[i]
+ " of type " + someParameters[i].getClass().getName());
throw new IllegalStateException(
"DebugFor325731: expected a ReferenceType or Primitive but was "
+ someParameters[i] + " of type "
+ someParameters[i].getClass().getName());
}
}
ret.append(">;");
@@ -1093,7 +1189,8 @@ public class ReferenceType extends ResolvedType {
}
}
ResolvedType[] newNewInterfaces = new ResolvedType[newInterfaces.length + 1];
System.arraycopy(newInterfaces, 0, newNewInterfaces, 1, newInterfaces.length);
System.arraycopy(newInterfaces, 0, newNewInterfaces, 1,
newInterfaces.length);
newNewInterfaces[0] = newParent;
newInterfaces = newNewInterfaces;
}
@@ -1101,7 +1198,7 @@ public class ReferenceType extends ResolvedType {
synchronized (derivativeTypes) {
for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
ReferenceType derivativeType = derivativeTypeRef.get();
if (derivativeType!=null) {
if (derivativeType != null) {
derivativeType.parameterizedInterfaces.clear();
}
}
@@ -1111,40 +1208,45 @@ public class ReferenceType extends ResolvedType {
}
}

private boolean equal(UnresolvedType[] typeParameters, ResolvedType[] resolvedParameters) {
if (typeParameters.length!=resolvedParameters.length) {
private boolean equal(UnresolvedType[] typeParameters,
ResolvedType[] resolvedParameters) {
if (typeParameters.length != resolvedParameters.length) {
return false;
}
int len = typeParameters.length;
for (int p=0;p<len;p++) {
for (int p = 0; p < len; p++) {
if (!typeParameters[p].equals(resolvedParameters[p])) {
return false;
}
}
return true;
}
/**
* Look for a derivative type with the specified type parameters. This can avoid creating an
* unnecessary new (duplicate) with the same information in it. This method also cleans up
* any reference entries that have been null'd by a GC.
* Look for a derivative type with the specified type parameters. This can
* avoid creating an unnecessary new (duplicate) with the same information
* in it. This method also cleans up any reference entries that have been
* null'd by a GC.
*
* @param typeParameters the type parameters to use when searching for the derivative type.
* @param typeParameters
* the type parameters to use when searching for the derivative
* type.
* @return an existing derivative type or null if there isn't one
*/
public ReferenceType findDerivativeType(ResolvedType[] typeParameters) {
synchronized (derivativeTypes) {
List<WeakReference<ReferenceType>> forRemoval = new ArrayList<WeakReference<ReferenceType>>();
for (WeakReference<ReferenceType> derivativeTypeRef: derivativeTypes) {
for (WeakReference<ReferenceType> derivativeTypeRef : derivativeTypes) {
ReferenceType derivativeType = derivativeTypeRef.get();
if (derivativeType==null) {
if (derivativeType == null) {
forRemoval.add(derivativeTypeRef);
} else {
if (derivativeType.isRawType()) {
continue;
}
if (equal(derivativeType.typeParameters,typeParameters)) {
return derivativeType; // this escape route wont remove the empty refs
if (equal(derivativeType.typeParameters, typeParameters)) {
return derivativeType; // this escape route wont remove
// the empty refs
}
}
}
@@ -1154,7 +1256,7 @@ public class ReferenceType extends ResolvedType {
}

public boolean hasNewInterfaces() {
return newInterfaces!=null;
return newInterfaces != null;
}

}

+ 3
- 5
org.aspectj.matcher/src/org/aspectj/weaver/UnresolvedType.java View File

@@ -259,7 +259,6 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
}

public static UnresolvedType forGenericType(String name, TypeVariable[] tvbs, String genericSig) {
// TODO asc generics needs a declared sig
String sig = nameToSignature(name);
UnresolvedType ret = UnresolvedType.forSignature(sig);
ret.typeKind = TypeKind.GENERIC;
@@ -921,8 +920,9 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
public String getPackageName() {
if (packageName == null) {
String name = getName();
if (name.indexOf("<") != -1) {
name = name.substring(0, name.indexOf("<"));
int angly = name.indexOf('<');
if (angly != -1) {
name = name.substring(0, angly);
}
int index = name.lastIndexOf('.');
if (index == -1) {
@@ -934,8 +934,6 @@ public class UnresolvedType implements Traceable, TypeVariableDeclaringElement {
return packageName;
}

// TODO these move to a TypeUtils class

public static void writeArray(UnresolvedType[] types, CompressingDataOutputStream stream) throws IOException {
int len = types.length;
stream.writeShort(len);

+ 0
- 2
org.aspectj.matcher/src/org/aspectj/weaver/World.java View File

@@ -1046,8 +1046,6 @@ public abstract class World implements Dump.INode {
private int collectedTypes = 0;
private final ReferenceQueue<ResolvedType> rq = new ReferenceQueue<ResolvedType>();

// private static Trace trace = TraceFactory.getTraceFactory().getTrace(World.TypeMap.class);

TypeMap(World w) {
// Demotion activated when switched on and loadtime weaving or in AJDT
demotionSystemActive = w.isDemotionActive() && (w.isLoadtimeWeaving() || w.couldIncrementalCompileFollow());

+ 8
- 2
org.aspectj.matcher/src/org/aspectj/weaver/patterns/AndPointcut.java View File

@@ -21,6 +21,7 @@ import org.aspectj.weaver.ISourceContext;
import org.aspectj.weaver.IntMap;
import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
import org.aspectj.weaver.ast.Test;
@@ -44,7 +45,11 @@ public class AndPointcut extends Pointcut {
}

public FuzzyBoolean fastMatch(FastMatchInfo type) {
return left.fastMatch(type).and(right.fastMatch(type));
FuzzyBoolean leftMatch = left.fastMatch(type);
if (leftMatch.alwaysFalse()) {
return leftMatch;
}
return leftMatch.and(right.fastMatch(type));
}

protected FuzzyBoolean matchInternal(Shadow shadow) {
@@ -104,7 +109,8 @@ public class AndPointcut extends Pointcut {
return ret;
}

public Pointcut parameterizeWith(Map typeVariableMap, World w) {
@Override
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) {
AndPointcut ret = new AndPointcut(left.parameterizeWith(typeVariableMap, w), right.parameterizeWith(typeVariableMap, w));
ret.copyLocationFrom(this);
ret.m_ignoreUnboundBindingForNames = m_ignoreUnboundBindingForNames;

+ 0
- 5
org.aspectj.matcher/src/org/aspectj/weaver/patterns/KindedPointcut.java View File

@@ -60,11 +60,6 @@ public class KindedPointcut extends Pointcut {
return signature;
}

/*
* (non-Javadoc)
*
* @see org.aspectj.weaver.patterns.Pointcut#couldMatchKinds()
*/
@Override
public int couldMatchKinds() {
return matchKinds;

+ 9
- 2
org.aspectj.matcher/src/org/aspectj/weaver/patterns/OrPointcut.java View File

@@ -24,6 +24,8 @@ import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.World;
import org.aspectj.weaver.ast.Test;
import org.aspectj.weaver.UnresolvedType;


public class OrPointcut extends Pointcut {
Pointcut left, right;
@@ -43,7 +45,11 @@ public class OrPointcut extends Pointcut {
}

public FuzzyBoolean fastMatch(FastMatchInfo type) {
return left.fastMatch(type).or(right.fastMatch(type));
FuzzyBoolean leftMatch = left.fastMatch(type);
if (leftMatch.alwaysTrue()) {
return leftMatch;
}
return leftMatch.or(right.fastMatch(type));
}

protected FuzzyBoolean matchInternal(Shadow shadow) {
@@ -112,7 +118,8 @@ public class OrPointcut extends Pointcut {
return ret;
}

public Pointcut parameterizeWith(Map typeVariableMap, World w) {
@Override
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) {
Pointcut ret = new OrPointcut(left.parameterizeWith(typeVariableMap, w), right.parameterizeWith(typeVariableMap, w));
ret.copyLocationFrom(this);
return ret;

+ 7
- 2
org.aspectj.matcher/src/org/aspectj/weaver/patterns/WithinPointcut.java View File

@@ -25,6 +25,7 @@ import org.aspectj.weaver.ResolvedType;
import org.aspectj.weaver.Shadow;
import org.aspectj.weaver.VersionedDataInputStream;
import org.aspectj.weaver.WeaverMessages;
import org.aspectj.weaver.UnresolvedType;
import org.aspectj.weaver.World;
import org.aspectj.weaver.ast.Literal;
import org.aspectj.weaver.ast.Test;
@@ -55,7 +56,8 @@ public class WithinPointcut extends Pointcut {
return Shadow.ALL_SHADOW_KINDS_BITS;
}

public Pointcut parameterizeWith(Map typeVariableMap, World w) {
@Override
public Pointcut parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w) {
WithinPointcut ret = new WithinPointcut(this.typePattern.parameterizeWith(typeVariableMap, w));
ret.copyLocationFrom(this);
return ret;
@@ -65,7 +67,10 @@ public class WithinPointcut extends Pointcut {
if (typePattern.annotationPattern instanceof AnyAnnotationTypePattern) {
return isWithinType(info.getType());
}
return FuzzyBoolean.MAYBE;
return FuzzyBoolean.MAYBE;
// Possible alternative implementation that fast matches even annotation patterns: '@Foo *'
// typePattern.resolve(info.world);
// return isWithinType(info.getType());
}

protected FuzzyBoolean matchInternal(Shadow shadow) {

BIN
org.eclipse.jdt.core/jdtcore-for-aspectj-src.zip View File


BIN
org.eclipse.jdt.core/jdtcore-for-aspectj.jar View File


+ 3
- 3
taskdefs/src/org/aspectj/tools/ant/taskdefs/AjcTask.java View File

@@ -253,9 +253,9 @@ public class AjcTask extends MatchingTask {

public static final String COMMAND_EDITOR_NAME = AjcTask.class.getName() + ".COMMAND_EDITOR";

static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7" };
static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7" };
static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7" };
static final String[] TARGET_INPUTS = new String[] { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8" };
static final String[] SOURCE_INPUTS = new String[] { "1.3", "1.4", "1.5", "1.6", "1.7", "1.8" };
static final String[] COMPLIANCE_INPUTS = new String[] { "-1.3", "-1.4", "-1.5", "-1.6", "-1.7", "-1.8" };

private static final ICommandEditor COMMAND_EDITOR;


+ 13
- 4
taskdefs/testsrc/org/aspectj/tools/ant/taskdefs/AjcTaskTest.java View File

@@ -524,7 +524,9 @@ public class AjcTaskTest extends TestCase {
Holder.class.getName());
String result = MESSAGES.toString();
MESSAGES.setLength(0);
assertEquals("messages", "e", result);
// The test program produces three errors with the current 1.8 compiler, this may change by 1.8 release and so
// this will need reverting back to "e"
assertEquals("messages", "eee", result);
}

// TODO skipped test - works locally but not on build machine?
@@ -590,7 +592,8 @@ public class AjcTaskTest extends TestCase {
final PrintStream serr = System.err;
try {
System.setErr(new PrintStream(new java.io.ByteArrayOutputStream()));
runTest(task, BuildException.class, MessageHolderChecker.ONE_ERROR);
// Current 1.8 compiler produces 3 errors for this test program, may need reverting to ONE_ERROR by release
runTest(task, BuildException.class, MessageHolderChecker.THREE_ERRORS);
} finally {
System.setErr(serr);
}
@@ -618,7 +621,10 @@ public class AjcTaskTest extends TestCase {
public void testCompileErrorList() {
AjcTask task = getTask("compileError.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR);
// Prior to the 1.8 compiler there is one error here, 'syntax error on here'
// With 1.8 there are 3 errors about completing the method header, ending the class body, ending the method - this may
// change by 1.8 final... this might need reverting back to ONE_ERROR
runTest(task, NO_EXCEPTION, MessageHolderChecker.THREE_ERRORS);
}
public void testShowWeaveInfo() {
@@ -703,7 +709,8 @@ public class AjcTaskTest extends TestCase {
public void testCompileErrorFile() {
AjcTask task = getTask("compileError.lst");
task.setFailonerror(false);
runTest(task, NO_EXCEPTION, MessageHolderChecker.ONE_ERROR);
// 1.8 compiler currently produces 3 errors for the test program, may need to revert to ONE_ERROR by 1.8 release
runTest(task, NO_EXCEPTION, MessageHolderChecker.THREE_ERRORS);
}

public void testCompileWarningFile() {
@@ -906,6 +913,8 @@ public class AjcTaskTest extends TestCase {
/** one warning, any number of info messages */
static MessageHolderChecker ONE_WARNING =
new MessageHolderChecker(0, 0, 0, 1, IGNORE);
static MessageHolderChecker THREE_ERRORS =
new MessageHolderChecker(0, 0, 3, 0, IGNORE);

int aborts, fails, errors, warnings, infos;

+ 12
- 10
testing/newsrc/org/aspectj/testing/AjcTest.java View File

@@ -1,13 +1,10 @@
/* *******************************************************************
* Copyright (c) 2004 IBM Corporation
* Copyright (c) 2004,2013 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
* which accompanies this distribution and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Adrian Colyer,
* ******************************************************************/
package org.aspectj.testing;

@@ -17,18 +14,17 @@ import java.util.List;
import org.aspectj.tools.ajc.AjcTestCase;

/**
* @author colyer
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
* @author Adrian Colyer
* @author Andy Clement
*/
public class AjcTest {
private static boolean is13VMOrGreater = true;
// private static boolean is13VMOrGreater = true;
private static boolean is14VMOrGreater = true;
private static boolean is15VMOrGreater = false;
private static boolean is16VMOrGreater = false;
private static boolean is17VMOrGreater = false;
private static boolean is18VMOrGreater = false;
static { // matching logic is also in org.aspectj.util.LangUtil
String vm = System.getProperty("java.version"); // JLS 20.18.7
@@ -44,7 +40,12 @@ public class AjcTest {
} else if (vm.startsWith("1.7")) {
is15VMOrGreater = true;
is16VMOrGreater = true;
is17VMOrGreater=true;
is17VMOrGreater = true;
} else if (vm.startsWith("1.8")) {
is15VMOrGreater = true;
is16VMOrGreater = true;
is17VMOrGreater = true;
is18VMOrGreater = true;
}
}

@@ -87,6 +88,7 @@ public class AjcTest {
if (vmLevel.equals("1.5")) canRun = is15VMOrGreater;
if (vmLevel.equals("1.6")) canRun = is16VMOrGreater;
if (vmLevel.equals("1.7")) canRun = is17VMOrGreater;
if (vmLevel.equals("1.8")) canRun = is18VMOrGreater;
if (!canRun) {
System.out.println("***SKIPPING TEST***" + getTitle()+ " needs " + getVmLevel()
+ ", currently running on " + System.getProperty("java.vm.version"));

+ 8
- 0
tests/bugs180/415957/MyAspect.aj View File

@@ -0,0 +1,8 @@
public aspect MyAspect {
pointcut all(): execution(@javax.annotation.Resource * *(..));


before(): all() {
System.out.println("Hi");
}
}

+ 5
- 0
tests/bugs180/415957/MyClass.java View File

@@ -0,0 +1,5 @@
public class MyClass {
@javax.annotation.Resource
public void method() {
}
}

+ 9
- 0
tests/bugs180/432178/A.java View File

@@ -0,0 +1,9 @@
public class A
{
public static void main(String [] args)
{
B test = new B();
test.met();
}
}


+ 7
- 0
tests/bugs180/432178/B.java View File

@@ -0,0 +1,7 @@
public class B
{
public void met()
{
System.out.println("foo");
}
}

+ 11
- 0
tests/bugs180/432178/PerCFlowBug.java View File

@@ -0,0 +1,11 @@
public abstract aspect PerCFlowBug percflow(pointexp())
{
String name = "bar";

abstract pointcut pointexp();

after() : pointexp()
{
System.out.println(name);
}
}

+ 9
- 0
tests/bugs180/432178/aop.xml View File

@@ -0,0 +1,9 @@
<aspectj>
<aspects>
<concrete-aspect name="PerCFlowBugImpl" extends="PerCFlowBug">
<pointcut name="pointexp" expression="(call (void *.met(..)))"/>
</concrete-aspect>
</aspects>
<weaver options="-verbose -debug -showWeaveInfo" >
</weaver>
</aspectj>

+ 45
- 0
tests/bugs180/firstprogram/C.java View File

@@ -0,0 +1,45 @@
import java.util.Arrays;


interface I {
// Default method
default void foo() {
System.out.println("ABC");
}
}

public class C implements I{
public static void main(String[] args) {
new C().foo();
// Lambda
Runnable r = () -> { System.out.println("hello world!"); };
r.run();
// Used Java8 b97
Arrays.asList(MyClass.doSomething()).forEach((p) -> System.out.println(p));
}
}

aspect X {
before(): execution(* I.foo()) {
System.out.println("I.foo running");
}
before(): staticinitialization(!X) {
System.out.println("Clazz "+thisJoinPointStaticPart);
}
}


class Utils {
public static int compareByLength(String in, String out) {
return in.length() - out.length();
}
}

class MyClass {
public static String[] doSomething() {
String []args = new String[]{"4444","333","22","1"};
// Method reference
Arrays.sort(args,Utils::compareByLength);
return args;
}
}

+ 16
- 0
tests/bugs180/pr431541/Test.aj View File

@@ -0,0 +1,16 @@
public aspect Test {
Object around(String s): call(public Object foo(String)) && args(s) {
return proceed(s);
}
}
class C {
public void m() {
foo("abc");
}
public Object foo(String s) {
return s;
}
}

+ 10
- 0
tests/bugs180/pr431976/Code.java View File

@@ -0,0 +1,10 @@
import org.aspectj.lang.annotation.SuppressAjWarnings;

privileged aspect BugThisJoinPoint {

@SuppressAjWarnings("adviceDidNotMatch")
void around(): execution(boolean forceFocus ()) {
thisJoinPoint.getThis();
}
}


+ 25
- 0
tests/bugs180/pr432714/Code.java View File

@@ -0,0 +1,25 @@
public class Code {
public static void main(String[]argv) {
}

public void foo(UID x) {
bar((x instanceof UID ? E.one : E.two));
}

public static void bar(FM fm) { }
}

aspect X {
void around(): execution(* foo(..)) {
}
}

class E {
static BBB one;
static CCC two;
class BBB extends FM<String> {}
class CCC extends FM<Long> {}
}
class FM<T> {}

class UID {}

+ 2
- 2
tests/features152/synchronization/transformed/expected/Investigation.c.txt View File

@@ -17,8 +17,8 @@
| | INVOKESPECIAL java.io.FileInputStream.<init> (Ljava/io/File;)V
| | POP
| catch java.io.IOException -> E0
| GOTO L0
| E0: POP (line 31)
| GOTO L0 (line 31)
| E0: POP
| GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 32)
| LDC "bang"
| INVOKEVIRTUAL java.io.PrintStream.println (Ljava/lang/String;)V

+ 2
- 2
tests/features152/synchronization/transformed/expected/One.c.txt View File

@@ -17,8 +17,8 @@
| | INVOKESPECIAL java.io.FileInputStream.<init> (Ljava/io/File;)V
| | POP
| catch java.io.IOException -> E0
| GOTO L0
| E0: POP (line 22)
| GOTO L0 (line 22)
| E0: POP
| GETSTATIC java.lang.System.out Ljava/io/PrintStream; (line 23)
| LDC "bang"
| INVOKESTATIC One.aspectOf ()LOne;

+ 2
- 2
tests/java5/ataspectj/ataspectj/aop-dumpproxy.xml View File

@@ -4,9 +4,9 @@
<aspect name="ataspectj.EmptyAspect"/>
</aspects>
<weaver>
<!--
<dump within="*..*Proxy*" beforeandafter="true"/>
-->
<!--
<dump within="*Proxy*" beforeandafter="true"/>
-->
</weaver>
</aspectj>

+ 30
- 0
tests/src/org/aspectj/systemtest/AllTests18.java View File

@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2013 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;

import junit.framework.Test;
import junit.framework.TestSuite;

import org.aspectj.systemtest.ajc180.AllTestsAspectJ180;

public class AllTests18 {

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
// $JUnit-BEGIN$
suite.addTest(AllTestsAspectJ180.suite());
suite.addTest(AllTests17.suite());
suite.addTest(AllTests16.suite());
suite.addTest(AllTests15.suite());
// $JUnit-END$
return suite;
}
}

+ 4
- 3
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java View File

@@ -540,9 +540,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("target(@Foo *)");
}

public void testErrorMessageOnITDWithTypePatterns() {
runTest("clear error message on itd with type pattern");
}
// ONE_EIGHT remove for now, needs some grammar changes to ensure empty type annotations are put in place for later consumption
// public void testErrorMessageOnITDWithTypePatterns() {
// runTest("clear error message on itd with type pattern");
// }

public void testAjKeywordsAsIdentifiers() {
runTest("before and after are valid identifiers in classes");

+ 2
- 1
tests/src/org/aspectj/systemtest/ajc150/DeclareAnnotationTests.java View File

@@ -18,6 +18,7 @@ import junit.framework.Test;
import org.aspectj.asm.AsmManager;
import org.aspectj.asm.IHierarchy;
import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.IRelationship;
import org.aspectj.testing.XMLBasedAjcTestCase;

public class DeclareAnnotationTests extends XMLBasedAjcTestCase {
@@ -299,7 +300,7 @@ public class DeclareAnnotationTests extends XMLBasedAjcTestCase {
"declare @type: p.q.DeathByAnnotations : @Colored(\"red\")");
assertTrue("Couldn't find 'declare @type' element in the tree", ipe != null);

List l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe);
List<IRelationship> l = AsmManager.lastActiveStructureModel.getRelationshipMap().get(ipe);
assertTrue("Should have a relationship but does not ", l != null && l.size() > 0);

ipe = top.findElementForLabel(top.getRoot(), IProgramElement.Kind.DECLARE_ANNOTATION_AT_METHOD,

+ 2
- 2
tests/src/org/aspectj/systemtest/ajc150/ataspectj/AtAjLTWTests.java View File

@@ -132,11 +132,11 @@ public class AtAjLTWTests extends XMLBasedAjcTestCase {

// The working directory is different because this test must be forked
File dir = new File("../tests/java5/ataspectj");
File f = new File(dir, "_ajdump/_before");
File f = new File(dir, "_ajdump/_before/com/sun/proxy");
CountingFilenameFilter cff = new CountingFilenameFilter(".class");
f.listFiles(cff);
assertEquals("Expected dump file in " + f.getAbsolutePath(), 1, cff.getCount());
f = new File(dir, "_ajdump");
f = new File(dir, "_ajdump/com/sun/proxy");
cff = new CountingFilenameFilter(".class");
f.listFiles(cff);
assertEquals(1, cff.getCount());

+ 2
- 0
tests/src/org/aspectj/systemtest/ajc153/ajc153.xml View File

@@ -286,7 +286,9 @@
<message kind="error" line="1" text="The import java.lang.retention cannot be resolved"/>
<message kind="error" line="3" text="Retention cannot be resolved to a type"/>
<message kind="error" line="3" text="RetentionPolicy cannot be resolved to a variable"/>
<!-- With 1.8 don't seem to get this now - assume it is because the annotation isn't being found
<message kind="error" line="3" text="The attribute value is undefined for the annotation type Retention"/>
-->
</compile>
</ajc-test>

+ 4
- 2
tests/src/org/aspectj/systemtest/ajc164/Ajc164Tests.java View File

@@ -355,12 +355,14 @@ public class Ajc164Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
runTest("debugging before advice - 2");
Method method = getMethodFromClass(getClassFrom(ajc.getSandboxDirectory(), "Foo2"), "foo");
// System.out.println(stringify(method.getLocalVariableTable()));
List l = sortedLocalVariables(method.getLocalVariableTable());
List<LocalVariable> l = sortedLocalVariables(method.getLocalVariableTable());
assertEquals("LBar; bar(1) start=0 len=34", stringify(l, 0));
assertEquals("Ljava/lang/Exception; e(3) start=29 len=4", stringify(l, 1));
assertEquals("LFoo2; this(0) start=0 len=34", stringify(l, 4));
assertEquals("Ljava/lang/String; s(2) start=15 len=19", stringify(l, 2));
assertEquals("Ljava/lang/String; s2(3) start=18 len=10", stringify(l, 3));
// With the 1.8 compiler looks like len=7 and not len=10 here, the goto to jump to the return is no longer included
// in the variable range
assertEquals("Ljava/lang/String; s2(3) start=18 len=7", stringify(l, 3));
}

// Two pieces of advice on before execution of a method with a this and a

+ 1
- 1
tests/src/org/aspectj/systemtest/ajc170/ajc170.xml View File

@@ -312,7 +312,7 @@
<ajc-test dir="bugs170/language" title="string switch 1">
<compile files="StringSwitch.java" options="-1.5">
<message kind="error" line="9" text="Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted"/>
<message kind="error" line="9" text="Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted"/>
</compile>
</ajc-test>


+ 59
- 0
tests/src/org/aspectj/systemtest/ajc180/Ajc180Tests.java View File

@@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright (c) 2013-2014 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.ajc180;

import java.io.File;

import junit.framework.Test;

import org.aspectj.testing.XMLBasedAjcTestCase;

/**
* @author Andy Clement
*/
public class Ajc180Tests extends org.aspectj.testing.XMLBasedAjcTestCase {

public void testPercflowLtw_432178() {
runTest("percflow ltw");
}
public void testStackmapframe_431976() {
runTest("stackmapframe");
}
public void testThisJoinPointNotInitialized_431976() {
runTest("thisJoinPoint not initialized");
}
public void testNullAnnotationMatching_431541() {
runTest("NullAnnotationMatching exception");
}
public void testAnnosWith18Flags_415957() {
runTest("annotations with 1.8 flags");
}
public void testJava8Code() throws Exception {
runTest("first advised java 8 code");
}
// ---

public static Test suite() {
return XMLBasedAjcTestCase.loadSuite(Ajc180Tests.class);
}

@Override
protected File getSpecFile() {
return new File("../tests/src/org/aspectj/systemtest/ajc180/ajc180.xml");
}

}

+ 25
- 0
tests/src/org/aspectj/systemtest/ajc180/AllTestsAspectJ180.java View File

@@ -0,0 +1,25 @@
/*******************************************************************************
* Copyright (c) 2013 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.ajc180;

import junit.framework.Test;
import junit.framework.TestSuite;

public class AllTestsAspectJ180 {

public static Test suite() {
TestSuite suite = new TestSuite("AspectJ 1.8.0 tests");
// $JUnit-BEGIN$
suite.addTest(Ajc180Tests.suite());
// $JUnit-END$
return suite;
}
}

+ 55
- 0
tests/src/org/aspectj/systemtest/ajc180/ajc180.xml View File

@@ -0,0 +1,55 @@
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>

<suite>

<ajc-test dir="bugs180/432178" title="percflow ltw">
<compile options="-1.8" files="A.java B.java"/>
<compile options="-1.8" files="PerCFlowBug.java"/>
<run class="A" ltw="aop.xml">
<stdout>
<line text="foo"/>
<line text="bar"/>
</stdout>
</run>
</ajc-test>
<ajc-test dir="bugs180/pr432714" title="stackmapframe">
<compile options="-1.8" files="Code.java"/>
<run class="Code"/>
</ajc-test>
<ajc-test dir="bugs180/pr431976" title="thisJoinPoint not initialized">
<compile options="-1.8" files="Code.java"/>
</ajc-test>

<ajc-test dir="bugs180/pr431541" title="NullAnnotationMatching exception">
<compile options="-1.8" files="Test.aj"/>
</ajc-test>
<ajc-test dir="bugs180/415957" title="annotations with 1.8 flags">
<compile files="MyAspect.aj MyClass.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)"/>
</compile>
</ajc-test>

<ajc-test dir="bugs180/firstprogram" title="first advised java 8 code">
<compile files="C.java" options="-1.8">
</compile>
<run class="C">
<stdout>
<line text="Clazz staticinitialization(I.&lt;clinit&gt;)"/>
<line text="Clazz staticinitialization(C.&lt;clinit&gt;)"/>
<line text="I.foo running"/>
<line text="ABC"/>
<line text="hello world!"/>
<line text="Clazz staticinitialization(MyClass.&lt;clinit&gt;)"/>
<line text="Clazz staticinitialization(Utils.&lt;clinit&gt;)"/>
<line text="1"/>
<line text="22"/>
<line text="333"/>
<line text="4444"/>
</stdout>
</run>
</ajc-test>

</suite>

+ 4
- 1
tests/testsrc/org/aspectj/tests/TestsModuleTests.java View File

@@ -19,6 +19,7 @@ import junit.framework.TestSuite;
import org.aspectj.systemtest.AllTests;
import org.aspectj.systemtest.AllTests14;
import org.aspectj.systemtest.AllTests17;
import org.aspectj.systemtest.AllTests18;
import org.aspectj.util.LangUtil;

public class TestsModuleTests extends TestCase {
@@ -27,7 +28,9 @@ public class TestsModuleTests extends TestCase {
String name = TestsModuleTests.class.getName();
TestSuite suite = new TestSuite(name);
// compiler tests, wrapped for JUnit
if (LangUtil.is15VMOrGreater()) {
if (LangUtil.is18VMOrGreater()) {
suite.addTest(AllTests18.suite());
} else if (LangUtil.is15VMOrGreater()) {
// suite.addTest(AllTests15.suite());
suite.addTest(AllTests17.suite()); // there are currently (28/11/06) no tests specific to a 1.6/1.7 vm - so we can do
// this

+ 0
- 1
util/src/org/aspectj/util/FuzzyBoolean.java View File

@@ -34,7 +34,6 @@ public abstract class FuzzyBoolean {
return true;
}


public boolean maybeFalse() {
return false;
}

+ 5
- 1
util/src/org/aspectj/util/LangUtil.java View File

@@ -74,7 +74,7 @@ public class LangUtil {
try {
String versionString = vm.substring(0, 3);
Double temp = new Double(Double.parseDouble(versionString));
vmVersion = temp.floatValue();
vmVersion = temp.doubleValue();
} catch (Exception e) {
vmVersion = 1.4;
}
@@ -106,6 +106,10 @@ public class LangUtil {
public static boolean is17VMOrGreater() {
return 1.7 <= vmVersion;
}
public static boolean is18VMOrGreater() {
return 1.8 <= vmVersion;
}

/**
* Shorthand for "if null, throw IllegalArgumentException"

+ 1
- 1
weaver/.classpath View File

@@ -13,6 +13,6 @@
<classpathentry kind="lib" path="/lib/bcel/bcel.jar" sourcepath="/lib/bcel/bcel-src.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.aspectj.matcher"/>
<classpathentry kind="lib" path="/lib/asm/asm-4.2.renamed.jar"/>
<classpathentry kind="lib" path="/lib/asm/asm-5.0.1.renamed.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

+ 1
- 3
weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java View File

@@ -162,8 +162,7 @@ public class BcelWeaver {
String fixedName = aspectName;
int hasDot = fixedName.lastIndexOf('.');
while (hasDot > 0) {
// System.out.println("BcelWeaver.addLibraryAspect " +
// fixedName);
// System.out.println("BcelWeaver.addLibraryAspect " + fixedName);
char[] fixedNameChars = fixedName.toCharArray();
fixedNameChars[hasDot] = '$';
fixedName = new String(fixedNameChars);
@@ -179,7 +178,6 @@ public class BcelWeaver {

// System.out.println("type: " + type + " for " + aspectName);
if (type.isAspect()) {

// Bug 119657 ensure we use the unwoven aspect
WeaverStateInfo wsi = type.getWeaverState();
if (wsi != null && wsi.isReweavable()) {

+ 6
- 3
weaver/src/org/aspectj/weaver/bcel/asm/StackMapAdder.java View File

@@ -50,7 +50,7 @@ public class StackMapAdder {
private static class AspectJClassVisitor extends ClassVisitor {

public AspectJClassVisitor(ClassVisitor classwriter) {
super(Opcodes.ASM4, classwriter);
super(Opcodes.ASM5, classwriter);
}

@Override
@@ -63,7 +63,7 @@ public class StackMapAdder {
// created by a ClassWriter (see top level class comment)
static class AJMethodVisitor extends MethodVisitor {
public AJMethodVisitor(MethodVisitor mv) {
super(Opcodes.ASM4,mv);
super(Opcodes.ASM5,mv);
}
}
@@ -96,7 +96,10 @@ public class StackMapAdder {
return "java/lang/Object";
} else {
do {
resolvedType1 = resolvedType1.getSuperclass().getRawType();
resolvedType1 = resolvedType1.getSuperclass();
if (resolvedType1.isParameterizedOrGenericType()) {
resolvedType1 = resolvedType1.getRawType();
}
} while (!resolvedType1.isAssignableFrom(resolvedType2));
return resolvedType1.getRawName().replace('.', '/');
}

Loading…
Cancel
Save