]> source.dussan.org Git - aspectj.git/commitdiff
Fix 490315 - InvokeDynamic.java:126 there is no classname for invokedynamic
authorAndy Clement <aclement@pivotal.io>
Tue, 29 Mar 2016 17:01:01 +0000 (10:01 -0700)
committerAndy Clement <aclement@pivotal.io>
Tue, 29 Mar 2016 17:01:01 +0000 (10:01 -0700)
17 files changed:
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/messages.properties
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
tests/bugs1810/490315/FailingAspect.java [new file with mode: 0755]
tests/bugs1810/490315/SomeAnno.java [new file with mode: 0755]
tests/bugs1810/490315/SomeContext.java [new file with mode: 0755]
tests/bugs1810/490315/SomeCriteria.java [new file with mode: 0755]
tests/bugs1810/490315/SomeDTO.java [new file with mode: 0755]
tests/bugs1810/490315/SomeEnum.java [new file with mode: 0755]
tests/bugs1810/490315/SomePiece.java [new file with mode: 0755]
tests/bugs1810/490315/SomePropertyDTO.java [new file with mode: 0755]
tests/bugs1810/490315/SomeService.java [new file with mode: 0755]
tests/bugs1810/490315/SomeServiceImpl.java [new file with mode: 0755]
tests/src/org/aspectj/systemtest/AllTests18.java
tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml [new file with mode: 0644]
weaver/src/org/aspectj/weaver/bcel/BcelAccessForInlineMunger.java

index 9218ada8867fb1c270002cbc6527851573dec8fc..185ab046cac43869c2ddc3ffb508e10e6b8292ff 100644 (file)
@@ -4,7 +4,7 @@
      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.8.9
+compiler.name = AspectJ Compiler 1.8.10
 compiler.version = Eclipse Compiler Mars.2 #A7BBA8B1, 3.12
 compiler.copyright = 
 
index dd38f775097326005768d805b5a81d678617525b..7da62b87c6f2d1950d8cdc11886998d277bfe9e0 100644 (file)
@@ -485,7 +485,12 @@ public class AsmHierarchyBuilder extends ASTVisitor {
                        }
                }
 
-               ((IProgramElement) stack.peek()).addChild(peNode);
+               IProgramElement ipe = (IProgramElement)stack.peek();
+               if (ipe!=null) {
+                       // With AspectJ 1.8.9 the type structure must be slightly different as the guard
+                       // is required (the null is due to a default constructor).
+                       ((IProgramElement) stack.peek()).addChild(peNode);
+               }
                stack.push(peNode);
                return true;
        }
diff --git a/tests/bugs1810/490315/FailingAspect.java b/tests/bugs1810/490315/FailingAspect.java
new file mode 100755 (executable)
index 0000000..4da1914
--- /dev/null
@@ -0,0 +1,27 @@
+package test;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+
+@Aspect
+public class FailingAspect {
+       
+    SomeContext authenticationContext;
+
+    @SuppressWarnings("unchecked")
+    @Around("execution(* test..SomeServiceImpl.someMethod(test.SomeCriteria))" +
+            "&& @annotation(test.SomeAnno)")
+    public SomePiece<Collection<SomeDTO>> interceptSomeMethod(ProceedingJoinPoint pjp) throws Throwable {
+        SomePiece<Collection<SomeDTO>> piece = (SomePiece<Collection<SomeDTO>>) pjp.proceed();
+        List<SomeDTO> filteredResult = piece.getData().stream().filter(item ->
+                authenticationContext.getPermissionDetails().checkAccess(
+                       item.getTag(), SomeEnum.R)).collect(Collectors.toList());
+        return new SomePiece<>(filteredResult, piece.isLast());
+    }
+
+}
diff --git a/tests/bugs1810/490315/SomeAnno.java b/tests/bugs1810/490315/SomeAnno.java
new file mode 100755 (executable)
index 0000000..112d3be
--- /dev/null
@@ -0,0 +1,4 @@
+package test;
+
+public @interface SomeAnno {
+}
diff --git a/tests/bugs1810/490315/SomeContext.java b/tests/bugs1810/490315/SomeContext.java
new file mode 100755 (executable)
index 0000000..4eeb7a6
--- /dev/null
@@ -0,0 +1,13 @@
+package test;\r
+\r
+public class SomeContext\r
+{\r
+       public SomeContext getPermissionDetails()\r
+       {\r
+               return this;\r
+       }\r
+       \r
+    public boolean checkAccess(String tag, SomeEnum accessType) {\r
+       return false;\r
+    }\r
+}\r
diff --git a/tests/bugs1810/490315/SomeCriteria.java b/tests/bugs1810/490315/SomeCriteria.java
new file mode 100755 (executable)
index 0000000..0a0a900
--- /dev/null
@@ -0,0 +1,7 @@
+package test;
+
+/**
+ */
+public final class SomeCriteria {
+
+}
diff --git a/tests/bugs1810/490315/SomeDTO.java b/tests/bugs1810/490315/SomeDTO.java
new file mode 100755 (executable)
index 0000000..d7bc67f
--- /dev/null
@@ -0,0 +1,10 @@
+package test;
+
+import java.io.Serializable;
+
+public class SomeDTO implements Serializable {
+
+    public String getTag() {
+        return "tag";
+    }
+}
diff --git a/tests/bugs1810/490315/SomeEnum.java b/tests/bugs1810/490315/SomeEnum.java
new file mode 100755 (executable)
index 0000000..1ec35b7
--- /dev/null
@@ -0,0 +1,5 @@
+package test;
+
+public enum SomeEnum {
+    R;
+}
diff --git a/tests/bugs1810/490315/SomePiece.java b/tests/bugs1810/490315/SomePiece.java
new file mode 100755 (executable)
index 0000000..d12548b
--- /dev/null
@@ -0,0 +1,30 @@
+package test;
+
+public class SomePiece<T> {
+
+    private T data;
+    private boolean last;
+    private Long totalCount;
+
+    public SomePiece(T data, boolean last) {
+        this.data = data;
+        this.last = last;
+    }
+
+    public T getData() {
+        return data;
+    }
+
+    public boolean isLast() {
+        return last;
+    }
+
+    public Long getTotalCount() {
+        return totalCount;
+    }
+
+    public void setTotalCount(Long totalCount) {
+        this.totalCount = totalCount;
+    }
+
+}
diff --git a/tests/bugs1810/490315/SomePropertyDTO.java b/tests/bugs1810/490315/SomePropertyDTO.java
new file mode 100755 (executable)
index 0000000..0f2a835
--- /dev/null
@@ -0,0 +1,17 @@
+package test;
+
+import java.io.Serializable;
+
+public class SomePropertyDTO implements Serializable, Comparable<SomePropertyDTO> {
+
+       /* (non-Javadoc)
+        * @see java.lang.Comparable#compareTo(java.lang.Object)
+        */
+       @Override
+       public int compareTo(SomePropertyDTO o)
+       {
+               // TODO Auto-generated method stub
+               return 0;
+       }
+       
+}
diff --git a/tests/bugs1810/490315/SomeService.java b/tests/bugs1810/490315/SomeService.java
new file mode 100755 (executable)
index 0000000..b24dea2
--- /dev/null
@@ -0,0 +1,8 @@
+package test;
+
+import java.util.Collection;
+
+public interface SomeService {
+
+    SomePiece<Collection<SomeDTO>> someMethod(SomeCriteria criteria);
+}
\ No newline at end of file
diff --git a/tests/bugs1810/490315/SomeServiceImpl.java b/tests/bugs1810/490315/SomeServiceImpl.java
new file mode 100755 (executable)
index 0000000..98a9978
--- /dev/null
@@ -0,0 +1,16 @@
+package test;
+
+import java.util.Collection;
+
+/**
+ */
+public class SomeServiceImpl implements SomeService {
+
+    @Override
+    @SomeAnno
+    public SomePiece<Collection<SomeDTO>> someMethod(SomeCriteria criteria) {
+       System.out.println("stuff");
+       
+       return null;
+    }
+}
\ No newline at end of file
index a5382792b88542992e60bc155a38d62eff757af9..2eadcb823d62abd8d29fda66bd4d2c182107e87f 100644 (file)
@@ -12,6 +12,7 @@ package org.aspectj.systemtest;
 
 import org.aspectj.systemtest.ajc180.AllTestsAspectJ180;
 import org.aspectj.systemtest.ajc181.AllTestsAspectJ181;
+import org.aspectj.systemtest.ajc1810.AllTestsAspectJ1810;
 import org.aspectj.systemtest.ajc182.AllTestsAspectJ182;
 import org.aspectj.systemtest.ajc183.AllTestsAspectJ183;
 import org.aspectj.systemtest.ajc184.AllTestsAspectJ184;
@@ -29,6 +30,7 @@ public class AllTests18 {
        public static Test suite() {
                TestSuite suite = new TestSuite("AspectJ System Test Suite - 1.8");
                // $JUnit-BEGIN$ 
+               suite.addTest(AllTestsAspectJ1810.suite()); 
                suite.addTest(AllTestsAspectJ189.suite()); 
                suite.addTest(AllTestsAspectJ188.suite()); 
                suite.addTest(AllTestsAspectJ187.suite()); 
diff --git a/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java b/tests/src/org/aspectj/systemtest/ajc1810/Ajc1810Tests.java
new file mode 100644 (file)
index 0000000..2cdf148
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.ajc1810;
+
+import java.io.File;
+
+import junit.framework.Test;
+
+import org.aspectj.apache.bcel.classfile.JavaClass;
+import org.aspectj.testing.XMLBasedAjcTestCase;
+
+/**
+ * @author Andy Clement
+ */
+public class Ajc1810Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
+
+       public void testInvokeDynamic_490315() {
+               runTest("indy");
+       }
+       
+//     public void testOverweaving_352389() throws Exception {
+//             runTest("overweaving");
+//     }
+       
+       // ---
+
+       public static Test suite() {
+               return XMLBasedAjcTestCase.loadSuite(Ajc1810Tests.class);
+       }
+
+       @Override
+       protected File getSpecFile() {
+               return getClassResource("ajc1810.xml");
+       }
+
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java b/tests/src/org/aspectj/systemtest/ajc1810/AllTestsAspectJ1810.java
new file mode 100644 (file)
index 0000000..b4fe6a8
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2016 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.ajc1810;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTestsAspectJ1810 {
+
+       public static Test suite() {
+               TestSuite suite = new TestSuite("AspectJ 1.8.10 tests");
+               // $JUnit-BEGIN$
+               suite.addTest(Ajc1810Tests.suite());
+               // $JUnit-END$
+               return suite;
+       }
+}
diff --git a/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml b/tests/src/org/aspectj/systemtest/ajc1810/ajc1810.xml
new file mode 100644 (file)
index 0000000..be1c3d5
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd"[]>
+
+<suite>
+
+       <ajc-test dir="bugs1810/490315" title="indy">
+               <compile options="-1.8" files="FailingAspect.java SomeAnno.java SomeContext.java SomeCriteria.java SomeDTO.java SomeEnum.java SomePiece.java SomePropertyDTO.java SomeService.java SomeServiceImpl.java"/>
+       </ajc-test>
+
+</suite>
index 9f84596f0c8725a63b66b6b6fc9ae26350af575a..b81f7ffb10b1b8617f24b22daac1d97f5d4e6fab 100644 (file)
@@ -27,6 +27,7 @@ import org.aspectj.apache.bcel.generic.InstructionConstants;
 import org.aspectj.apache.bcel.generic.InstructionFactory;
 import org.aspectj.apache.bcel.generic.InstructionHandle;
 import org.aspectj.apache.bcel.generic.InstructionList;
+import org.aspectj.apache.bcel.generic.InvokeDynamic;
 import org.aspectj.apache.bcel.generic.InvokeInstruction;
 import org.aspectj.apache.bcel.generic.Type;
 import org.aspectj.weaver.AjAttribute;
@@ -138,6 +139,10 @@ public class BcelAccessForInlineMunger extends BcelTypeMunger {
                        // open-up method call
                        if ((inst instanceof InvokeInstruction)) {
                                InvokeInstruction invoke = (InvokeInstruction) inst;
+                               if (invoke instanceof InvokeDynamic) {
+                                       realizedCannotInline = true;
+                                       break;
+                               }
                                ResolvedType callee = aspectGen.getWorld().resolve(UnresolvedType.forName(invoke.getClassName(cpg)));
 
                                // look in the whole method list and not just declared for super calls and alike