issue_id
int64
2.04k
425k
title
stringlengths
9
251
body
stringlengths
4
32.8k
status
stringclasses
6 values
after_fix_sha
stringlengths
7
7
project_name
stringclasses
6 values
repo_url
stringclasses
6 values
repo_name
stringclasses
6 values
language
stringclasses
1 value
issue_url
null
before_fix_sha
null
pull_url
null
commit_datetime
timestamp[us, tz=UTC]
report_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
23
187
chunk_content
stringlengths
1
22k
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
org.aspectj.matcher/src/org/aspectj/weaver/patterns/WildAnnotationTypePattern.java
ret.annotationValues = aValues; } } return ret; } @Override public boolean equals(Object obj) { if (!(obj instanceof WildAnnotationTypePattern)) { return false; } WildAnnotationTypePattern other = (WildAnnotationTypePattern) obj; return other.typePattern.equals(typePattern) && this.isForParameterAnnotationMatch() == other.isForParameterAnnotationMatch() && (annotationValues == null ? other.annotationValues == null : annotationValues.equals(other.annotationValues)); } @Override public int hashCode() { return (((17 + 37 * typePattern.hashCode()) * 37 + (isForParameterAnnotationMatch() ? 0 : 1)) * 37) + (annotationValues == null ? 0 : annotationValues.hashCode()); } @Override public String toString() { return "@(" + typePattern.toString() + ")"; } @Override public Object accept(PatternNodeVisitor visitor, Object data) { return visitor.visit(this, data); } }
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
/******************************************************************************* * Copyright (c) 2012 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.ajc172; import java.io.File; import junit.framework.Test; import org.aspectj.apache.bcel.classfile.JavaClass; import org.aspectj.apache.bcel.classfile.Method; import org.aspectj.testing.XMLBasedAjcTestCase; /** * @author Andy Clement */ public class Ajc172Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public void testSignatures_pr394535() throws Exception { runTest("signatures"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Bug2$ClassA2"); String sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T::LBug2$Interface12;:LBug2$Interface22;>Ljava/lang/Object;Ljava/io/Serializable;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Bug$ClassA"); sss = jc.getSignatureAttribute().getSignature();
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
assertEquals("<T::LBug$Interface1;:LBug$Interface2;>Ljava/lang/Object;Ljava/io/Serializable;", sss); } public void testPSignatures_pr399590() throws Exception { runTest("p signatures 1"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); String sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal<+LCage<TT;>;>;>LBar;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal2<+LCage2<TT;>;>;>LBar2;Ljava/io/Serializable;", sss); } public void testPSignatures_pr399590_2() throws Exception { runTest("p signatures 2"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); String sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal<+LCage<TT;LIntf;>;LIntf;>;Q:Ljava/lang/Object;>LBar;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal2<+LCage2<TT;LIntf2;>;LIntf2;>;Q:Ljava/lang/Object;>LBar2;Ljava/io/Serializable;", sss); } public void testPSignatures_pr399590_3() throws Exception { runTest("p signatures 3"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); String sss = jc.getSignatureAttribute().getSignature();
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
assertEquals("<T:LAnimal<-LXXX<TT;>;>;>LBar;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal2<-LXXX2<TT;>;>;>LBar2;Ljava/io/Serializable;", sss); } public void testPSignatures_pr399590_4() throws Exception { runTest("p signatures 4"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); String sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal<-LXXX<TT;>;LYYY;>;>LBar;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal2<-LXXX2<TT;>;LYYY2;>;>LBar2;Ljava/io/Serializable;", sss); } public void testPSignatures_pr399590_5() throws Exception { runTest("p signatures 5"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(),"Cage"); String sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal<*>;>LBar;", sss); jc = getClassFrom(ajc.getSandboxDirectory(),"Cage2"); sss = jc.getSignatureAttribute().getSignature(); assertEquals("<T:LAnimal2<*>;>LBar2;Ljava/io/Serializable;", sss); } public void testIfPointcutNames_pr398246() throws Exception { runTest("if pointcut names"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if"); assertEquals("ajc$if$andy", m.getName());
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
} public void testIfPointcutNames_pr398246_2() throws Exception { runTest("if pointcut names 2"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if"); assertEquals("ajc$if$fred", m.getName()); } public void testIfPointcutNames_pr398246_3() throws Exception { runTest("if pointcut names 3"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if"); assertEquals("ajc$if$barney", m.getName()); } public void testIfPointcutNames_pr398246_4() throws Exception { runTest("if pointcut names 4"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if"); assertEquals("ajc$if$sid", m.getName()); } public void testIfPointcutNames_pr398246_5() throws Exception { runTest("if pointcut names 5"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if"); assertEquals("ajc$if$ac0cb804", m.getName()); jc = getClassFrom(ajc.getSandboxDirectory(), "X2"); m = getMethodStartsWith(jc, "ajc$if");
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
assertEquals("ajc$if$ac0cb804", m.getName()); } public void testIfPointcutNames_pr398246_6() throws Exception { runTest("if pointcut names 6"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if",1); assertEquals("ajc$if$aac93da8", m.getName()); m = getMethodStartsWith(jc, "ajc$if",2); assertEquals("ajc$if$1$ae5e778a", m.getName()); } public void testIfPointcutNames_pr398246_7() throws Exception { runTest("if pointcut names 7"); JavaClass jc = getClassFrom(ajc.getSandboxDirectory(), "X"); Method m = getMethodStartsWith(jc, "ajc$if",1); assertEquals("ajc$if$1$ac0607c", m.getName()); m = getMethodStartsWith(jc, "ajc$if",2); assertEquals("ajc$if$1$1$4d4baf36", m.getName()); } public void testOptionalAspects_pr398588() { runTest("optional aspects"); } public void testInconsistentClassFile_pr389750() { runTest("inconsistent class file"); } public void testInconsistentClassFile_pr389750_2() { runTest("inconsistent class file 2"); } public void testInconsistentClassFile_pr389750_3() {
391,384
Bug 391384 WildAnnotationTypePattern.java:231
OK, I get that this is not supported (and what I *want* here is matching on the existence of the supplied header *among* the headers in the String[]). A feature request might be in order, but a syntax for specifying how you want to match the array would be needed.... The bug that I'm reporting is that trying to *save* this program gets an error that pops up a dialog. This should just become another error marker. It might the compiler that has to change what it throws, but in the end it's the Eclipse IDE that ends up breaking from a user standpoint. (RequestMapping.headers() is of type String[]). public aspect Fail { pointcut testable(): execution(public * @RequestMapping(headers="x-test=test") com.example..*(..)); } java.lang.RuntimeException at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveAnnotationValues(WildAnnotationTypePattern.java:231) at org.aspectj.weaver.patterns.WildAnnotationTypePattern.resolveBindings(WildAnnotationTypePattern.java:325) at org.aspectj.weaver.patterns.WildTypePattern.resolveBindings(WildTypePattern.java:657) at org.aspectj.weaver.patterns.SignaturePattern.resolveBindings(SignaturePattern.java:81) at org.a ... n(Worker.java:53) Compile error: RuntimeException thrown: Compiler limitation: annotation value support not implemented for type java.lang.String[]
resolved fixed
edb41e3
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-05T19:14:40Z
2012-10-09T05:20:00Z
tests/src/org/aspectj/systemtest/ajc172/Ajc172Tests.java
runTest("inconsistent class file 3"); } public void testInconsistentClassFile_pr389750_4() { runTest("inconsistent class file 4"); } public void testAnnotationValueError_pr389752_1() { runTest("annotation value error 1"); } public void testAnnotationValueError_pr389752_2() { runTest("annotation value error 2"); } public static Test suite() { return XMLBasedAjcTestCase.loadSuite(Ajc172Tests.class); } @Override protected File getSpecFile() { return new File("../tests/src/org/aspectj/systemtest/ajc172/ajc172.xml"); } }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
/* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). * 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: * PARC initial implementation * ******************************************************************/ package org.aspectj.weaver; import java.lang.reflect.Modifier; /** * The AjcMemberMaker is responsible for creating the representations of methods/fields/etc that are placed in both aspects and * affected target types. It uses the NameMangler class to create the actual names that will be used. */ public class AjcMemberMaker { private static final int PUBLIC_STATIC_FINAL = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
private static final int PRIVATE_STATIC = Modifier.PRIVATE | Modifier.STATIC; private static final int PUBLIC_STATIC = Modifier.PUBLIC | Modifier.STATIC; private static final int BRIDGE = 0x0040; private static final int VISIBILITY = Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED; public static final UnresolvedType CFLOW_STACK_TYPE = UnresolvedType.forName(NameMangler.CFLOW_STACK_TYPE); public static final UnresolvedType AROUND_CLOSURE_TYPE = UnresolvedType .forSignature("Lorg/aspectj/runtime/internal/AroundClosure;"); public static final UnresolvedType CONVERSIONS_TYPE = UnresolvedType.forSignature("Lorg/aspectj/runtime/internal/Conversions;"); public static final UnresolvedType NO_ASPECT_BOUND_EXCEPTION = UnresolvedType .forSignature("Lorg/aspectj/lang/NoAspectBoundException;"); public static ResolvedMember ajcPreClinitMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PRIVATE_STATIC, NameMangler.AJC_PRE_CLINIT_NAME, "()V"); } public static ResolvedMember ajcPostClinitMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PRIVATE_STATIC, NameMangler.AJC_POST_CLINIT_NAME, "()V"); } public static Member noAspectBoundExceptionInit() { return new ResolvedMemberImpl(Member.METHOD, NO_ASPECT_BOUND_EXCEPTION, Modifier.PUBLIC, "<init>", "()V"); } public static Member noAspectBoundExceptionInit2() { return new ResolvedMemberImpl(Member.METHOD, NO_ASPECT_BOUND_EXCEPTION, Modifier.PUBLIC, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); } public static Member noAspectBoundExceptionInitWithCause() { return new ResolvedMemberImpl(Member.METHOD, NO_ASPECT_BOUND_EXCEPTION, Modifier.PUBLIC, "<init>", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); } public static ResolvedMember perCflowPush(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, NameMangler.PERCFLOW_PUSH_METHOD, "()V"); }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
public static ResolvedMember perCflowField(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.FIELD, declaringType, PUBLIC_STATIC_FINAL, NameMangler.PERCFLOW_FIELD_NAME, CFLOW_STACK_TYPE.getSignature()); } public static ResolvedMember perSingletonField(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.FIELD, declaringType, PUBLIC_STATIC_FINAL, NameMangler.PERSINGLETON_FIELD_NAME, declaringType.getSignature()); } public static ResolvedMember initFailureCauseField(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.FIELD, declaringType, PRIVATE_STATIC, NameMangler.INITFAILURECAUSE_FIELD_NAME, UnresolvedType.THROWABLE.getSignature()); } public static ResolvedMember perObjectField(UnresolvedType declaringType, ResolvedType aspectType) { int modifiers = Modifier.PRIVATE; if (!UnresolvedType.SERIALIZABLE.resolve(aspectType.getWorld()).isAssignableFrom(aspectType)) { modifiers |= Modifier.TRANSIENT; } return new ResolvedMemberImpl(Member.FIELD, declaringType, modifiers, aspectType, NameMangler.perObjectInterfaceField(aspectType), UnresolvedType.NONE); } public static ResolvedMember perTypeWithinField(UnresolvedType declaringType, ResolvedType aspectType) { int modifiers = Modifier.PRIVATE | Modifier.STATIC; if (!isSerializableAspect(aspectType)) { modifiers |= Modifier.TRANSIENT; } return new ResolvedMemberImpl(Member.FIELD, declaringType, modifiers, aspectType, NameMangler.perTypeWithinFieldForTarget(aspectType), UnresolvedType.NONE); }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
public static ResolvedMember perTypeWithinWithinTypeField(UnresolvedType declaringType, ResolvedType aspectType) { int modifiers = Modifier.PRIVATE; if (!isSerializableAspect(aspectType)) { modifiers |= Modifier.TRANSIENT; } return new ResolvedMemberImpl(Member.FIELD, declaringType, modifiers, UnresolvedType.JL_STRING, NameMangler.PERTYPEWITHIN_WITHINTYPEFIELD, UnresolvedType.NONE); } private static boolean isSerializableAspect(ResolvedType aspectType) { return UnresolvedType.SERIALIZABLE.resolve(aspectType.getWorld()).isAssignableFrom(aspectType); } public static ResolvedMember perObjectBind(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, NameMangler.PEROBJECT_BIND_METHOD, "(Ljava/lang/Object;)V"); } public static ResolvedMember perTypeWithinGetInstance(UnresolvedType declaringType) { ResolvedMemberImpl rm = new ResolvedMemberImpl(Member.METHOD, declaringType, PRIVATE_STATIC, declaringType, NameMangler.PERTYPEWITHIN_GETINSTANCE_METHOD, new UnresolvedType[] { UnresolvedType.JL_CLASS }); return rm; } public static ResolvedMember perTypeWithinGetWithinTypeNameMethod(UnresolvedType declaringType, boolean inJava5Mode) { ResolvedMemberImpl rm = new ResolvedMemberImpl(Member.METHOD, declaringType, Modifier.PUBLIC, UnresolvedType.JL_STRING, NameMangler.PERTYPEWITHIN_GETWITHINTYPENAME_METHOD, UnresolvedType.NONE); return rm;
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} public static ResolvedMember perTypeWithinCreateAspectInstance(UnresolvedType declaringType) { ResolvedMemberImpl rm = new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, declaringType, NameMangler.PERTYPEWITHIN_CREATEASPECTINSTANCE_METHOD, new UnresolvedType[] { UnresolvedType.forSignature("Ljava/lang/String;") }, new UnresolvedType[] {}); return rm; } public static UnresolvedType perObjectInterfaceType(UnresolvedType aspectType) { return UnresolvedType.forName(aspectType.getName() + "$ajcMightHaveAspect"); } public static ResolvedMember perObjectInterfaceGet(UnresolvedType aspectType) { return new ResolvedMemberImpl(Member.METHOD, perObjectInterfaceType(aspectType), Modifier.PUBLIC | Modifier.ABSTRACT, NameMangler.perObjectInterfaceGet(aspectType), "()" + aspectType.getSignature()); } public static ResolvedMember perObjectInterfaceSet(UnresolvedType aspectType) { return new ResolvedMemberImpl(Member.METHOD, perObjectInterfaceType(aspectType), Modifier.PUBLIC | Modifier.ABSTRACT, NameMangler.perObjectInterfaceSet(aspectType), "(" + aspectType.getSignature() + ")V"); } public static ResolvedMember perTypeWithinLocalAspectOf(UnresolvedType shadowType, UnresolvedType aspectType) { return new ResolvedMemberImpl(Member.METHOD, shadowType, Modifier.PUBLIC | Modifier.STATIC, NameMangler.perTypeWithinLocalAspectOf(aspectType), "()" + aspectType.getSignature()); } public static ResolvedMember perSingletonAspectOfMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "aspectOf", "()" + declaringType.getSignature()); } public static ResolvedMember perSingletonHasAspectMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "hasAspect", "()Z");
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} public static ResolvedMember perCflowAspectOfMethod(UnresolvedType declaringType) { return perSingletonAspectOfMethod(declaringType); } public static ResolvedMember perCflowHasAspectMethod(UnresolvedType declaringType) { return perSingletonHasAspectMethod(declaringType); } public static ResolvedMember perObjectAspectOfMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "aspectOf", "(Ljava/lang/Object;)" + declaringType.getSignature()); } public static ResolvedMember perObjectHasAspectMethod(UnresolvedType declaringType) { return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, "hasAspect", "(Ljava/lang/Object;)Z"); } public static ResolvedMember perTypeWithinAspectOfMethod(UnresolvedType declaringType, boolean inJava5Mode) { UnresolvedType parameterType = null; if (inJava5Mode) { parameterType = UnresolvedType.forRawTypeName("java.lang.Class"); } else { parameterType = UnresolvedType.forSignature("Ljava/lang/Class;"); } return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, declaringType, "aspectOf", new UnresolvedType[] { parameterType }); } /* * public static ResolvedMember perTypeWithinGetWithinTypeMethod(UnresolvedType declaringType, boolean inJava5Mode) {
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
* UnresolvedType returnType = null; if (inJava5Mode) { returnType = UnresolvedType.forRawTypeName("java.lang.Class"); } else { * returnType = UnresolvedType.forSignature("Ljava/lang/Class;"); } return new * ResolvedMemberImpl(Member.METHOD,declaringType,Modifier.PUBLIC,ResolvedType.JAVA_LANG_STRING,"getWithinType",new * UnresolvedType[]{}); } */ public static ResolvedMember perTypeWithinHasAspectMethod(UnresolvedType declaringType, boolean inJava5Mode) { UnresolvedType parameterType = null; if (inJava5Mode) { parameterType = UnresolvedType.forRawTypeName("java.lang.Class"); } else { parameterType = UnresolvedType.forSignature("Ljava/lang/Class;"); } return new ResolvedMemberImpl(Member.METHOD, declaringType, PUBLIC_STATIC, UnresolvedType.BOOLEAN, "hasAspect", new UnresolvedType[] { parameterType }); } public static ResolvedMember privilegedAccessMethodForMethod(UnresolvedType aspectType, ResolvedMember method) { return new ResolvedMemberImpl(Member.METHOD, method.getDeclaringType(), Modifier.PUBLIC | (Modifier.isStatic(method.getModifiers()) ? Modifier.STATIC : 0), method.getReturnType(), NameMangler.privilegedAccessMethodForMethod(method.getName(), method.getDeclaringType(), aspectType), method.getParameterTypes(), method.getExceptions()); } /** * Return a resolvedmember representing the synthetic getter for the field. The old style (<1.6.9) is a heavyweight static * method with a long name. The new style (1.6.9 and later) is short, and reusable across aspects. *
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
* @param aspectType the aspect attempting the access * @param field the field to be accessed * @param shortSyntax is the old (long) or new (short) style format being used * @return a resolvedmember representing the synthetic getter */ public static ResolvedMember privilegedAccessMethodForFieldGet(UnresolvedType aspectType, Member field, boolean shortSyntax) { UnresolvedType fieldDeclaringType = field.getDeclaringType(); if (shortSyntax) { UnresolvedType[] args = null; if (Modifier.isStatic(field.getModifiers())) { args = ResolvedType.NONE; } else { args = new UnresolvedType[] { fieldDeclaringType }; } StringBuffer name = new StringBuffer("ajc$get$"); name.append(field.getName()); return new ResolvedMemberImpl(Member.METHOD, fieldDeclaringType, PUBLIC_STATIC, field.getReturnType(), name.toString(), args); } else { String getterName = NameMangler.privilegedAccessMethodForFieldGet(field.getName(), fieldDeclaringType, aspectType); String sig; if (Modifier.isStatic(field.getModifiers())) { sig = "()" + field.getReturnType().getSignature(); } else { sig = "(" + fieldDeclaringType.getSignature() + ")" + field.getReturnType().getSignature(); } return new ResolvedMemberImpl(Member.METHOD, fieldDeclaringType, PUBLIC_STATIC, getterName, sig); } } /**
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
* Return a resolvedmember representing the synthetic setter for the field. The old style (<1.6.9) is a heavyweight static * method with a long name. The new style (1.6.9 and later) is short, not always static, and reusable across aspects. * * @param aspectType the aspect attempting the access * @param field the field to be accessed * @param shortSyntax is the old or new style format being used * @return a resolvedmember representing the synthetic setter */ public static ResolvedMember privilegedAccessMethodForFieldSet(UnresolvedType aspectType, Member field, boolean shortSyntax) { UnresolvedType fieldDeclaringType = field.getDeclaringType(); if (shortSyntax) { UnresolvedType[] args = null; if (Modifier.isStatic(field.getModifiers())) { args = new UnresolvedType[] { field.getType() }; } else { args = new UnresolvedType[] { fieldDeclaringType, field.getType() }; } StringBuffer name = new StringBuffer("ajc$set$"); name.append(field.getName()); return new ResolvedMemberImpl(Member.METHOD, fieldDeclaringType, PUBLIC_STATIC, UnresolvedType.VOID, name.toString(), args); } else { String setterName = NameMangler.privilegedAccessMethodForFieldSet(field.getName(), fieldDeclaringType, aspectType); String sig; if (Modifier.isStatic(field.getModifiers())) { sig = "(" + field.getReturnType().getSignature() + ")V"; } else { sig = "(" + fieldDeclaringType.getSignature() + field.getReturnType().getSignature() + ")V"; } return new ResolvedMemberImpl(Member.METHOD, fieldDeclaringType, PUBLIC_STATIC, setterName, sig);
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} } public static ResolvedMember superAccessMethod(UnresolvedType baseType, ResolvedMember method) { UnresolvedType[] paramTypes = method.getParameterTypes(); return new ResolvedMemberImpl(Member.METHOD, baseType, Modifier.PUBLIC, method.getReturnType(), NameMangler.superDispatchMethod(baseType, method.getName()), paramTypes, method.getExceptions()); } public static ResolvedMember inlineAccessMethodForMethod(UnresolvedType aspectType, ResolvedMember method) { UnresolvedType[] paramTypes = method.getParameterTypes(); if (!Modifier.isStatic(method.getModifiers())) { paramTypes = UnresolvedType.insert(method.getDeclaringType(), paramTypes); } return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, method.getReturnType(), NameMangler.inlineAccessMethodForMethod(method.getName(), method.getDeclaringType(), aspectType), paramTypes, method.getExceptions()); } public static ResolvedMember inlineAccessMethodForFieldGet(UnresolvedType aspectType, Member field) { String sig; if (Modifier.isStatic(field.getModifiers())) { sig = "()" + field.getReturnType().getSignature(); } else { sig = "(" + field.getDeclaringType().getSignature() + ")" + field.getReturnType().getSignature();
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, NameMangler.inlineAccessMethodForFieldGet(field.getName(), field.getDeclaringType(), aspectType), sig); } public static ResolvedMember inlineAccessMethodForFieldSet(UnresolvedType aspectType, Member field) { String sig; if (Modifier.isStatic(field.getModifiers())) { sig = "(" + field.getReturnType().getSignature() + ")V"; } else { sig = "(" + field.getDeclaringType().getSignature() + field.getReturnType().getSignature() + ")V"; } return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, NameMangler.inlineAccessMethodForFieldSet(field.getName(), field.getDeclaringType(), aspectType), sig); } public static Member cflowStackPeekInstance() { return new MemberImpl(Member.METHOD, CFLOW_STACK_TYPE, 0, "peekInstance", "()Ljava/lang/Object;"); } public static Member cflowStackPushInstance() { return new MemberImpl(Member.METHOD, CFLOW_STACK_TYPE, 0, "pushInstance", "(Ljava/lang/Object;)V"); } public static Member cflowStackIsValid() { return new MemberImpl(Member.METHOD, CFLOW_STACK_TYPE, 0, "isValid", "()Z"); } public static Member cflowStackInit() { return new MemberImpl(Member.CONSTRUCTOR, CFLOW_STACK_TYPE, 0, "<init>", "()V"); } public static Member aroundClosurePreInitializationField() {
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
return new MemberImpl(Member.FIELD, AROUND_CLOSURE_TYPE, 0, "preInitializationState", "[Ljava/lang/Object;"); } public static Member aroundClosurePreInitializationGetter() { return new MemberImpl(Member.METHOD, AROUND_CLOSURE_TYPE, 0, "getPreInitializationState", "()[Ljava/lang/Object;"); } public static ResolvedMember preIntroducedConstructor(UnresolvedType aspectType, UnresolvedType targetType, UnresolvedType[] paramTypes) { return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC_FINAL, UnresolvedType.OBJECTARRAY, NameMangler.preIntroducedConstructor(aspectType, targetType), paramTypes); } public static ResolvedMember postIntroducedConstructor(UnresolvedType aspectType, UnresolvedType targetType, UnresolvedType[] paramTypes) { return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC_FINAL, UnresolvedType.VOID, NameMangler.postIntroducedConstructor(aspectType, targetType), UnresolvedType.insert(targetType, paramTypes)); } public static ResolvedMember itdAtDeclareParentsField(ResolvedType targetType, UnresolvedType itdType, UnresolvedType aspectType) { return new ResolvedMemberImpl(Member.FIELD, targetType, Modifier.PRIVATE, itdType, NameMangler.itdAtDeclareParentsField( aspectType, itdType), null); } public static ResolvedMember interConstructor(ResolvedType targetType, ResolvedMember constructor, UnresolvedType aspectType) { ResolvedMember ret = new ResolvedMemberImpl(Member.CONSTRUCTOR, targetType, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", constructor.getParameterTypes(), constructor.getExceptions()); if (Modifier.isPublic(constructor.getModifiers())) { return ret;
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} while (true) { ret = addCookieTo(ret, aspectType); if (targetType.lookupMemberNoSupers(ret) == null) { return ret; } } } public static ResolvedMember interFieldInitializer(ResolvedMember field, UnresolvedType aspectType) { return new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, NameMangler.interFieldInitializer(aspectType, field.getDeclaringType(), field.getName()), Modifier.isStatic(field.getModifiers()) ? "()V" : "(" + field.getDeclaringType().getSignature() + ")V"); } private static int makePublicNonFinal(int modifiers) { return (modifiers & ~VISIBILITY & ~Modifier.FINAL) | Modifier.PUBLIC; } private static int makeNonFinal(int modifiers) { return (modifiers & ~Modifier.FINAL); } /** * This static method goes on the aspect that declares the inter-type field */ public static ResolvedMember interFieldSetDispatcher(ResolvedMember field, UnresolvedType aspectType) { ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, UnresolvedType.VOID, NameMangler.interFieldSetDispatcher(aspectType, field.getDeclaringType(), field.getName()), Modifier.isStatic(field .getModifiers()) ? new UnresolvedType[] { field.getReturnType() } : new UnresolvedType[] { field.getDeclaringType(), field.getReturnType() }); rm.setTypeVariables(field.getTypeVariables()); return rm; }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
/** * This static method goes on the aspect that declares the inter-type field */ public static ResolvedMember interFieldGetDispatcher(ResolvedMember field, UnresolvedType aspectType) { ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, field.getReturnType(), NameMangler.interFieldGetDispatcher(aspectType, field.getDeclaringType(), field.getName()), Modifier.isStatic(field .getModifiers()) ? UnresolvedType.NONE : new UnresolvedType[] { field.getDeclaringType() }, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; } /** * This field goes on the class the field is declared onto. Field names for ITDs onto interfaces are handled below. */ public static ResolvedMember interFieldClassField(ResolvedMember field, UnresolvedType aspectType, boolean newStyle) { int modifiers = (newStyle ? makeNonFinal(field.getModifiers()) : makePublicNonFinal(field.getModifiers())); String name = null; if (newStyle) { name = field.getName(); } else { name = NameMangler.interFieldClassField(field.getModifiers(), aspectType, field.getDeclaringType(), field.getName()); } return new ResolvedMemberImpl(Member.FIELD, field.getDeclaringType(), modifiers, field.getReturnType(), name, UnresolvedType.NONE, UnresolvedType.NONE);
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} /** * This field goes on top-most implementers of the interface the field is declared onto */ public static ResolvedMember interFieldInterfaceField(ResolvedMember field, UnresolvedType onClass, UnresolvedType aspectType, boolean newStyle) { String name = null; if (newStyle) { name = field.getName(); } else { name = NameMangler.interFieldInterfaceField(aspectType, field.getDeclaringType(), field.getName()); } return new ResolvedMemberImpl(Member.FIELD, onClass, makePublicNonFinal(field.getModifiers()), field.getReturnType(), name, UnresolvedType.NONE, UnresolvedType.NONE); } /** * This instance method goes on the interface the field is declared onto as well as its top-most implementors */ public static ResolvedMember interFieldInterfaceSetter(ResolvedMember field, ResolvedType onType, UnresolvedType aspectType) { int modifiers = Modifier.PUBLIC; if (onType.isInterface()) { modifiers |= Modifier.ABSTRACT; } ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, onType, modifiers, UnresolvedType.VOID, NameMangler.interFieldInterfaceSetter(aspectType, field.getDeclaringType(), field.getName()), new UnresolvedType[] { field.getReturnType() }, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; } /** * This instance method goes on the interface the field is declared onto as well as its top-most implementors
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
*/ public static ResolvedMember interFieldInterfaceGetter(ResolvedMember field, ResolvedType onType, UnresolvedType aspectType) { int modifiers = Modifier.PUBLIC; if (onType.isInterface()) { modifiers |= Modifier.ABSTRACT; } ResolvedMember rm = new ResolvedMemberImpl(Member.METHOD, onType, modifiers, field.getReturnType(), NameMangler.interFieldInterfaceGetter(aspectType, field.getDeclaringType(), field.getName()), UnresolvedType.NONE, UnresolvedType.NONE); rm.setTypeVariables(field.getTypeVariables()); return rm; } /** * This method goes on the target type of the inter-type method. (and possibly the topmost-implementors, if the target type is * an interface). The implementation will call the interMethodDispatch method on the aspect. */ public static ResolvedMember interMethod(ResolvedMember meth, UnresolvedType aspectType, boolean onInterface) { if (Modifier.isPublic(meth.getModifiers()) && !onInterface) { return meth; } int modifiers = makePublicNonFinal(meth.getModifiers()); if (onInterface) { modifiers |= Modifier.ABSTRACT; } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(), modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setParameterNames(meth.getParameterNames()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi;
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
} /** * This method goes on the target type of the inter-type method. (and possibly the topmost-implementors, if the target type is * an interface). The implementation will call the interMethodDispatch method on the aspect. */ public static ResolvedMember interMethodBridger(ResolvedMember meth, UnresolvedType aspectType, boolean onInterface) { int modifiers = makePublicNonFinal(meth.getModifiers()) | BRIDGE; if (onInterface) { modifiers |= Modifier.ABSTRACT; } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, meth.getDeclaringType(), modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; } /** * Sometimes the intertyped method requires a bridge method alongside it. For example if the method 'N SomeI<N>.m()' is put onto * an interface 'interface I<N extends Number>' and then a concrete implementation is 'class C implements I<Float>' then the ITD * on the interface will be 'Number m()', whereas the ITD on the 'topmostimplementor' will be 'Float m()'. A bridge method needs * to be created in the topmostimplementor 'Number m()' that delegates to 'Float m()' */ public static ResolvedMember bridgerToInterMethod(ResolvedMember meth, UnresolvedType aspectType) { int modifiers = makePublicNonFinal(meth.getModifiers()); ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, modifiers, meth.getReturnType(), NameMangler.interMethod(meth.getModifiers(), aspectType, meth.getDeclaringType(), meth.getName()), meth.getParameterTypes(), meth.getExceptions()); rmi.setTypeVariables(meth.getTypeVariables());
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
return rmi; } /** * This static method goes on the declaring aspect of the inter-type method. The implementation calls the interMethodBody() * method on the aspect. */ public static ResolvedMember interMethodDispatcher(ResolvedMember meth, UnresolvedType aspectType) { UnresolvedType[] paramTypes = meth.getParameterTypes(); if (!Modifier.isStatic(meth.getModifiers())) { paramTypes = UnresolvedType.insert(meth.getDeclaringType(), paramTypes); } ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, PUBLIC_STATIC, meth.getReturnType(), NameMangler.interMethodDispatcher(aspectType, meth.getDeclaringType(), meth.getName()), paramTypes, meth.getExceptions()); rmi.setParameterNames(meth.getParameterNames()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; } /** * This method goes on the declaring aspect of the inter-type method. It contains the real body of the ITD method. */ public static ResolvedMember interMethodBody(ResolvedMember meth, UnresolvedType aspectType) { UnresolvedType[] paramTypes = meth.getParameterTypes(); if (!Modifier.isStatic(meth.getModifiers())) { paramTypes = UnresolvedType.insert(meth.getDeclaringType(), paramTypes); } int modifiers = PUBLIC_STATIC; if (Modifier.isStrict(meth.getModifiers())) { modifiers |= Modifier.STRICT; }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
ResolvedMemberImpl rmi = new ResolvedMemberImpl(Member.METHOD, aspectType, modifiers, meth.getReturnType(), NameMangler.interMethodBody(aspectType, meth.getDeclaringType(), meth.getName()), paramTypes, meth.getExceptions()); rmi.setParameterNames(meth.getParameterNames()); rmi.setTypeVariables(meth.getTypeVariables()); return rmi; } private static ResolvedMember addCookieTo(ResolvedMember ret, UnresolvedType aspectType) { UnresolvedType[] params = ret.getParameterTypes(); UnresolvedType[] freshParams = UnresolvedType.add(params, aspectType); return new ResolvedMemberImpl(ret.getKind(), ret.getDeclaringType(), ret.getModifiers(), ret.getReturnType(), ret.getName(), freshParams, ret.getExceptions()); } public static ResolvedMember toObjectConversionMethod(UnresolvedType fromType) { if (fromType.isPrimitiveType()) { String name = fromType.toString() + "Object"; return new ResolvedMemberImpl(Member.METHOD, CONVERSIONS_TYPE, PUBLIC_STATIC, UnresolvedType.OBJECT, name, new UnresolvedType[] { fromType }, UnresolvedType.NONE); } else { return null; } } public static Member interfaceConstructor(ResolvedType resolvedTypeX) { ResolvedType declaringType = resolvedTypeX; if (declaringType.isRawType()) { declaringType = declaringType.getGenericType(); } return new ResolvedMemberImpl(Member.CONSTRUCTOR, declaringType, Modifier.PUBLIC, "<init>", "()V"); }
318,878
Bug 318878 Pertarget aspect instantiation is not thread-safe
The way in which pertarget aspects compiled with ajc check if a given target already has an aspect is not thread safe. When two different threads trigger an advice on a target object for the first time at the same time, sometimes the aspect for that target gets created twice. The following code demonstrates the problem: The following pertarget aspect will add itself to a (synchronized) set in another class in it's constructor. aspect Pertarget pertarget(execution(void foo())) { public Pertarget() { Main.aspects.add(this); // Add this instance to the set in Main } before(): execution(void foo()) {} // Empty advice to trigger creation } This class creates 10000 target objects and has two separate threads call a method (that causes the aspect to be instantiated) on each object. The aspects add themselves to the "aspects" set and this set's size is printed when all threads have finished. import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; public class Main { public static Set aspects = Collections.synchronizedSet( Collections.newSetFromMap(new IdentityHashMap())); public static void main(String[] args) throws InterruptedException { for (int i = 0; i < 10000; ++i) { final Main m = new Main(); // Create a new target for the aspect Runnable r = new Runnable() { public void run() { m.foo(); } // This will trigger the advice }; Thread t1 = new Thread(r); Thread t2 = new Thread(r); t1.start(); t2.start(); t1.join(); t2.join(); } System.out.println(aspects.size()); // Should be 10000 } private void foo() {} } When compiled with ajc and run, the main method prints values over 10000 (something like 10030-10060 typically), which means that some target objects get multiple aspect instances. In my own application I sometimes also saw some threads accessing partially built aspect instances. This was quite rare however and I wasn't able to make a test case for it. The ajc version (the current stable) used was: AspectJ Compiler 1.6.8 (1.6.8 - Built: Friday Jan 8, 2010 at 21:53:37 GMT) - Eclipse Compiler 0.785_R33x, 3.3 The sun vm version was: Java(TM) SE Runtime Environment (build 1.6.0_20-b02) Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01, mixed mode) I investigated the source of this problem: the ajc compiler generates the following (decompiled) method into the aspect class: public static void ajc$perObjectBind(Object obj) { if((obj instanceof ajcMightHaveAspect) && ((ajcMightHaveAspect)obj).perObjectGet() == null) ((ajcMightHaveAspect)obj).perObjectSet(new Pertarget()); } , which obviously is not thread safe.
resolved fixed
be5a530
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-02-25T23:18:12Z
2010-07-05T11:40:00Z
org.aspectj.matcher/src/org/aspectj/weaver/AjcMemberMaker.java
public final static UnresolvedType ASPECT_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/Aspect;"); public final static UnresolvedType BEFORE_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/Before;"); public final static UnresolvedType AROUND_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/Around;"); public final static UnresolvedType AFTERRETURNING_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/AfterReturning;"); public final static UnresolvedType AFTERTHROWING_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/AfterThrowing;"); public final static UnresolvedType AFTER_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/After;"); public final static UnresolvedType POINTCUT_ANNOTATION = UnresolvedType.forSignature("Lorg/aspectj/lang/annotation/Pointcut;"); public final static UnresolvedType DECLAREERROR_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/DeclareError;"); public final static UnresolvedType DECLAREWARNING_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/DeclareWarning;"); public final static UnresolvedType DECLAREPRECEDENCE_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/DeclarePrecedence;"); public final static UnresolvedType DECLAREPARENTS_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/DeclareParents;"); public final static UnresolvedType DECLAREMIXIN_ANNOTATION = UnresolvedType .forSignature("Lorg/aspectj/lang/annotation/DeclareMixin;"); public final static UnresolvedType TYPEX_JOINPOINT = UnresolvedType.forSignature("Lorg/aspectj/lang/JoinPoint;"); public final static UnresolvedType TYPEX_PROCEEDINGJOINPOINT = UnresolvedType .forSignature("Lorg/aspectj/lang/ProceedingJoinPoint;"); public final static UnresolvedType TYPEX_STATICJOINPOINT = UnresolvedType .forSignature("Lorg/aspectj/lang/JoinPoint$StaticPart;"); public final static UnresolvedType TYPEX_ENCLOSINGSTATICJOINPOINT = UnresolvedType .forSignature("Lorg/aspectj/lang/JoinPoint$EnclosingStaticPart;"); }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
/* ******************************************************************* * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). * 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
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* http:www.eclipse.org/legal/epl-v10.html * * Contributors: * PARC initial implementation * Alexandre Vasseur @AspectJ ITDs * ******************************************************************/ package org.aspectj.weaver; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Queue; import java.util.Set; import org.aspectj.bridge.IMessage; import org.aspectj.bridge.ISourceLocation; import org.aspectj.bridge.Message; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; import org.aspectj.weaver.Iterators.Getter; import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.PerClause; public abstract class ResolvedType extends UnresolvedType implements AnnotatedElement {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public static final ResolvedType[] EMPTY_RESOLVED_TYPE_ARRAY = new ResolvedType[0]; public static final String PARAMETERIZED_TYPE_IDENTIFIER = "P"; public ResolvedType[] temporaryAnnotationTypes; private ResolvedType[] resolvedTypeParams; private String binaryPath; protected World world; private int bits; private static int AnnotationBitsInitialized = 0x0001; private static int AnnotationMarkedInherited = 0x0002; private static int MungersAnalyzed = 0x0004; private static int HasParentMunger = 0x0008; private static int TypeHierarchyCompleteBit = 0x0010; private static int GroovyObjectInitialized = 0x0020; private static int IsGroovyObject = 0x0040; protected ResolvedType(String signature, World world) { super(signature); this.world = world; } protected ResolvedType(String signature, String signatureErasure, World world) { super(signature, signatureErasure); this.world = world; } public int getSize() {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return 1; } /** * Returns an iterator through ResolvedType objects representing all the direct supertypes of this type. That is, through the * superclass, if any, and all declared interfaces. */ public final Iterator<ResolvedType> getDirectSupertypes() { Iterator<ResolvedType> interfacesIterator = Iterators.array(getDeclaredInterfaces()); ResolvedType superclass = getSuperclass(); if (superclass == null) { return interfacesIterator; } else { return Iterators.snoc(interfacesIterator, superclass); } } public abstract ResolvedMember[] getDeclaredFields(); public abstract ResolvedMember[] getDeclaredMethods(); public abstract ResolvedType[] getDeclaredInterfaces(); public abstract ResolvedMember[] getDeclaredPointcuts(); public boolean isCacheable() { return true; } /** * @return the superclass of this type, or null (if this represents a jlObject, primitive, or void) */ public abstract ResolvedType getSuperclass(); public abstract int getModifiers(); public boolean isMissing() { return false;
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} public static boolean isMissing(UnresolvedType unresolved) { if (unresolved instanceof ResolvedType) { ResolvedType resolved = (ResolvedType) unresolved; return resolved.isMissing(); } else { return (unresolved == MISSING); } } public ResolvedType[] getAnnotationTypes() { return EMPTY_RESOLVED_TYPE_ARRAY; } public AnnotationAJ getAnnotationOfType(UnresolvedType ofType) { return null; } protected static Set<String> validBoxing = new HashSet<String>(); static { validBoxing.add("Ljava/lang/Byte;B"); validBoxing.add("Ljava/lang/Character;C"); validBoxing.add("Ljava/lang/Double;D"); validBoxing.add("Ljava/lang/Float;F");
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
validBoxing.add("Ljava/lang/Integer;I"); validBoxing.add("Ljava/lang/Long;J"); validBoxing.add("Ljava/lang/Short;S"); validBoxing.add("Ljava/lang/Boolean;Z"); validBoxing.add("BLjava/lang/Byte;"); validBoxing.add("CLjava/lang/Character;"); validBoxing.add("DLjava/lang/Double;"); validBoxing.add("FLjava/lang/Float;"); validBoxing.add("ILjava/lang/Integer;"); validBoxing.add("JLjava/lang/Long;"); validBoxing.add("SLjava/lang/Short;"); validBoxing.add("ZLjava/lang/Boolean;"); } public ResolvedType getResolvedComponentType() { return null; } public World getWorld() { return world; } @Override public boolean equals(Object other) { if (other instanceof ResolvedType) { return this == other; } else { return super.equals(other); } }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
/** * returns an iterator through all of the fields of this type, in order for checking from JVM spec 2ed 5.4.3.2. This means that * the order is * <p/> * <ul> * <li>fields from current class</li> * <li>recur into direct superinterfaces</li> * <li>recur into superclass</li> * </ul> * <p/> * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. */ public Iterator<ResolvedMember> getFields() { final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { public Iterator<ResolvedType> get(ResolvedType o) { return dupFilter.filter(o.getDirectSupertypes()); } }; return Iterators.mapOver(Iterators.recur(this, typeGetter), FieldGetterInstance); } /** * returns an iterator through all of the methods of this type, in order for checking from JVM spec 2ed 5.4.3.3. This means that * the order is * <p/> * <ul> * <li>methods from current class</li> * <li>recur into superclass, all the way up, not touching interfaces</li> * <li>recur into all superinterfaces, in some unspecified order (but those 'closest' to this type are first)</li> * </ul>
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* <p/> * * @param wantGenerics is true if the caller would like all generics information, otherwise those methods are collapsed to their * erasure */ public Iterator<ResolvedMember> getMethods(boolean wantGenerics, boolean wantDeclaredParents) { return Iterators.mapOver(getHierarchy(wantGenerics, wantDeclaredParents), MethodGetterInstance); } public Iterator<ResolvedMember> getMethodsIncludingIntertypeDeclarations(boolean wantGenerics, boolean wantDeclaredParents) { return Iterators.mapOver(getHierarchy(wantGenerics, wantDeclaredParents), MethodGetterWithItdsInstance); } /** * An Iterators.Getter that returns an iterator over all methods declared on some resolved type. */ private static class MethodGetter implements Iterators.Getter<ResolvedType, ResolvedMember> { public Iterator<ResolvedMember> get(ResolvedType type) { return Iterators.array(type.getDeclaredMethods()); } } /** * An Iterators.Getter that returns an iterator over all pointcuts declared on some resolved type. */ private static class PointcutGetter implements Iterators.Getter<ResolvedType, ResolvedMember> { public Iterator<ResolvedMember> get(ResolvedType o) { return Iterators.array(o.getDeclaredPointcuts()); } } private static class MethodGetterIncludingItds implements Iterators.Getter<ResolvedType, ResolvedMember> {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public Iterator<ResolvedMember> get(ResolvedType type) { ResolvedMember[] methods = type.getDeclaredMethods(); if (type.interTypeMungers != null) { int additional = 0; for (ConcreteTypeMunger typeTransformer : type.interTypeMungers) { ResolvedMember rm = typeTransformer.getSignature(); if (rm != null) { additional++; } } if (additional > 0) { ResolvedMember[] methods2 = new ResolvedMember[methods.length + additional]; System.arraycopy(methods, 0, methods2, 0, methods.length); additional = methods.length; for (ConcreteTypeMunger typeTransformer : type.interTypeMungers) { ResolvedMember rm = typeTransformer.getSignature(); if (rm != null) { methods2[additional++] = typeTransformer.getSignature(); } } methods = methods2; } } return Iterators.array(methods); } } /**
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* An Iterators.Getter that returns an iterator over all fields declared on some resolved type. */ private static class FieldGetter implements Iterators.Getter<ResolvedType, ResolvedMember> { public Iterator<ResolvedMember> get(ResolvedType type) { return Iterators.array(type.getDeclaredFields()); } } private final static MethodGetter MethodGetterInstance = new MethodGetter(); private final static MethodGetterIncludingItds MethodGetterWithItdsInstance = new MethodGetterIncludingItds(); private final static PointcutGetter PointcutGetterInstance = new PointcutGetter(); private final static FieldGetter FieldGetterInstance = new FieldGetter(); /** * Return an iterator over the types in this types hierarchy - starting with this type first, then all superclasses up to Object * and then all interfaces (starting with those 'nearest' this type). * * @param wantGenerics true if the caller wants full generic information * @param wantDeclaredParents true if the caller even wants those parents introduced via declare parents * @return an iterator over all types in the hierarchy of this type */ public Iterator<ResolvedType> getHierarchy() { return getHierarchy(false, false); } public Iterator<ResolvedType> getHierarchy(final boolean wantGenerics, final boolean wantDeclaredParents) { final Iterators.Getter<ResolvedType, ResolvedType> interfaceGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { List<String> alreadySeen = new ArrayList<String>(); public Iterator<ResolvedType> get(ResolvedType type) { ResolvedType[] interfaces = type.getDeclaredInterfaces(); if (!wantDeclaredParents && type.hasNewParentMungers()) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
List<Integer> forRemoval = new ArrayList<Integer>(); for (ConcreteTypeMunger munger : type.interTypeMungers) { if (munger.getMunger() != null) { ResolvedTypeMunger m = munger.getMunger(); if (m.getKind() == ResolvedTypeMunger.Parent) { ResolvedType newType = ((NewParentTypeMunger) m).getNewParent(); if (!wantGenerics && newType.isParameterizedOrGenericType()) { newType = newType.getRawType(); } for (int ii = 0; ii < interfaces.length; ii++) { ResolvedType iface = interfaces[ii]; if (!wantGenerics && iface.isParameterizedOrGenericType()) { iface = iface.getRawType(); } if (newType.getSignature().equals(iface.getSignature())) { forRemoval.add(ii); } } } } } if (forRemoval.size() > 0) { ResolvedType[] interfaces2 = new ResolvedType[interfaces.length - forRemoval.size()]; int p = 0; for (int ii = 0; ii < interfaces.length; ii++) { if (!forRemoval.contains(ii)) { interfaces2[p++] = interfaces[ii]; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} interfaces = interfaces2; } } return new Iterators.ResolvedTypeArrayIterator(interfaces, alreadySeen, wantGenerics); } }; if (this.isInterface()) { return new SuperInterfaceWalker(interfaceGetter, this); } else { SuperInterfaceWalker superInterfaceWalker = new SuperInterfaceWalker(interfaceGetter); Iterator<ResolvedType> superClassesIterator = new SuperClassWalker(this, superInterfaceWalker, wantGenerics); return Iterators.append1(superClassesIterator, superInterfaceWalker); } } /** * Return a list of methods, first those declared on this class, then those declared on the superclass (recurse) and then those * declared on the superinterfaces. This is expensive - use the getMethods() method if you can! */ public List<ResolvedMember> getMethodsWithoutIterator(boolean includeITDs, boolean allowMissing, boolean genericsAware) { List<ResolvedMember> methods = new ArrayList<ResolvedMember>(); Set<String> knowninterfaces = new HashSet<String>(); addAndRecurse(knowninterfaces, methods, this, includeITDs, allowMissing, genericsAware); return methods; } /** * Return a list of the types in the hierarchy of this type, starting with this type. The order in the list is the superclasses
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* followed by the super interfaces. * * @param genericsAware should the list include parameterized/generic types (if not, they will be collapsed to raw)? * @return list of resolvedtypes in this types hierarchy, including this type first */ public List<ResolvedType> getHierarchyWithoutIterator(boolean includeITDs, boolean allowMissing, boolean genericsAware) { List<ResolvedType> types = new ArrayList<ResolvedType>(); Set<String> visited = new HashSet<String>(); recurseHierarchy(visited, types, this, includeITDs, allowMissing, genericsAware); return types; } private void addAndRecurse(Set<String> knowninterfaces, List<ResolvedMember> collector, ResolvedType resolvedType, boolean includeITDs, boolean allowMissing, boolean genericsAware) { collector.addAll(Arrays.asList(resolvedType.getDeclaredMethods())); if (includeITDs && resolvedType.interTypeMungers != null) { for (ConcreteTypeMunger typeTransformer : interTypeMungers) { ResolvedMember rm = typeTransformer.getSignature(); if (rm != null) { collector.add(typeTransformer.getSignature()); } } } if (!resolvedType.isInterface() && !resolvedType.equals(ResolvedType.OBJECT)) { ResolvedType superType = resolvedType.getSuperclass(); if (superType != null && !superType.isMissing()) { if (!genericsAware && superType.isParameterizedOrGenericType()) { superType = superType.getRawType();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} addAndRecurse(knowninterfaces, collector, superType, includeITDs, allowMissing, genericsAware); } } ResolvedType[] interfaces = resolvedType.getDeclaredInterfaces(); for (int i = 0; i < interfaces.length; i++) { ResolvedType iface = interfaces[i]; if (!genericsAware && iface.isParameterizedOrGenericType()) { iface = iface.getRawType(); } boolean shouldSkip = false; for (int j = 0; j < resolvedType.interTypeMungers.size(); j++) { ConcreteTypeMunger munger = resolvedType.interTypeMungers.get(j); if (munger.getMunger() != null && munger.getMunger().getKind() == ResolvedTypeMunger.Parent && ((NewParentTypeMunger) munger.getMunger()).getNewParent().equals(iface) ) { shouldSkip = true; break; } } if (!shouldSkip && !knowninterfaces.contains(iface.getSignature())) { knowninterfaces.add(iface.getSignature()); if (allowMissing && iface.isMissing()) { if (iface instanceof MissingResolvedTypeWithKnownSignature) { ((MissingResolvedTypeWithKnownSignature) iface).raiseWarningOnMissingInterfaceWhilstFindingMethods();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} } else { addAndRecurse(knowninterfaces, collector, iface, includeITDs, allowMissing, genericsAware); } } } } /** * Recurse up a type hierarchy, first the superclasses then the super interfaces. */ private void recurseHierarchy(Set<String> knowninterfaces, List<ResolvedType> collector, ResolvedType resolvedType, boolean includeITDs, boolean allowMissing, boolean genericsAware) { collector.add(resolvedType); if (!resolvedType.isInterface() && !resolvedType.equals(ResolvedType.OBJECT)) { ResolvedType superType = resolvedType.getSuperclass(); if (superType != null && !superType.isMissing()) { if (!genericsAware && (superType.isParameterizedType() || superType.isGenericType())) { superType = superType.getRawType(); } recurseHierarchy(knowninterfaces, collector, superType, includeITDs, allowMissing, genericsAware); } } ResolvedType[] interfaces = resolvedType.getDeclaredInterfaces(); for (int i = 0; i < interfaces.length; i++) { ResolvedType iface = interfaces[i]; if (!genericsAware && (iface.isParameterizedType() || iface.isGenericType())) { iface = iface.getRawType(); }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
boolean shouldSkip = false; for (int j = 0; j < resolvedType.interTypeMungers.size(); j++) { ConcreteTypeMunger munger = resolvedType.interTypeMungers.get(j); if (munger.getMunger() != null && munger.getMunger().getKind() == ResolvedTypeMunger.Parent && ((NewParentTypeMunger) munger.getMunger()).getNewParent().equals(iface) ) { shouldSkip = true; break; } } if (!shouldSkip && !knowninterfaces.contains(iface.getSignature())) { knowninterfaces.add(iface.getSignature()); if (allowMissing && iface.isMissing()) { if (iface instanceof MissingResolvedTypeWithKnownSignature) { ((MissingResolvedTypeWithKnownSignature) iface).raiseWarningOnMissingInterfaceWhilstFindingMethods(); } } else { recurseHierarchy(knowninterfaces, collector, iface, includeITDs, allowMissing, genericsAware); } } } } public ResolvedType[] getResolvedTypeParameters() { if (resolvedTypeParams == null) { resolvedTypeParams = world.resolve(typeParameters); } return resolvedTypeParams;
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} /** * described in JVM spec 2ed 5.4.3.2 */ public ResolvedMember lookupField(Member field) { Iterator<ResolvedMember> i = getFields(); while (i.hasNext()) { ResolvedMember resolvedMember = i.next(); if (matches(resolvedMember, field)) { return resolvedMember; } if (resolvedMember.hasBackingGenericMember() && field.getName().equals(resolvedMember.getName())) { if (matches(resolvedMember.getBackingGenericMember(), field)) { return resolvedMember; } } } return null; } /** * described in JVM spec 2ed 5.4.3.3. Doesnt check ITDs. * * <p> * Check the current type for the method. If it is not found, check the super class and any super interfaces. Taking care not to * process interfaces multiple times. */ public ResolvedMember lookupMethod(Member m) { List<ResolvedType> typesTolookat = new ArrayList<ResolvedType>(); typesTolookat.add(this);
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
int pos = 0; while (pos < typesTolookat.size()) { ResolvedType type = typesTolookat.get(pos++); if (!type.isMissing()) { ResolvedMember[] methods = type.getDeclaredMethods(); if (methods != null) { for (int i = 0; i < methods.length; i++) { ResolvedMember method = methods[i]; if (matches(method, m)) { return method; } if (method.hasBackingGenericMember() && m.getName().equals(method.getName())) { if (matches(method.getBackingGenericMember(), m)) { return method; } } } } } ResolvedType superclass = type.getSuperclass(); if (superclass != null) { typesTolookat.add(superclass); } ResolvedType[] superinterfaces = type.getDeclaredInterfaces(); if (superinterfaces != null) { for (int i = 0; i < superinterfaces.length; i++) { ResolvedType interf = superinterfaces[i];
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (!typesTolookat.contains(interf)) { typesTolookat.add(interf); } } } } return null; } /** * @param member the member to lookup in intertype declarations affecting this type * @return the real signature defined by any matching intertype declaration, otherwise null */ public ResolvedMember lookupMethodInITDs(Member member) { for (ConcreteTypeMunger typeTransformer : interTypeMungers) { if (matches(typeTransformer.getSignature(), member)) { return typeTransformer.getSignature(); } } return null; } /** * return null if not found */ private ResolvedMember lookupMember(Member m, ResolvedMember[] a) { for (int i = 0; i < a.length; i++) { ResolvedMember f = a[i]; if (matches(f, m)) { return f; } }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return null; } /** * Looks for the first member in the hierarchy matching aMember. This method differs from lookupMember(Member) in that it takes * into account parameters which are type variables - which clearly an unresolved Member cannot do since it does not know * anything about type variables. */ public ResolvedMember lookupResolvedMember(ResolvedMember aMember, boolean allowMissing, boolean eraseGenerics) { Iterator<ResolvedMember> toSearch = null; ResolvedMember found = null; if ((aMember.getKind() == Member.METHOD) || (aMember.getKind() == Member.CONSTRUCTOR)) { toSearch = getMethodsIncludingIntertypeDeclarations(!eraseGenerics, true); } else { assert aMember.getKind() == Member.FIELD; toSearch = getFields(); } while (toSearch.hasNext()) { ResolvedMember candidate = toSearch.next(); if (eraseGenerics) { if (candidate.hasBackingGenericMember()) { candidate = candidate.getBackingGenericMember(); } } if (candidate.matches(aMember, eraseGenerics)) { found = candidate; break; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} return found; } public static boolean matches(Member m1, Member m2) { if (m1 == null) { return m2 == null; } if (m2 == null) { return false; } boolean equalNames = m1.getName().equals(m2.getName()); if (!equalNames) { return false; } boolean equalSignatures = m1.getSignature().equals(m2.getSignature()); if (equalSignatures) { return true; } boolean equalCovariantSignatures = m1.getParameterSignature().equals(m2.getParameterSignature()); if (equalCovariantSignatures) { return true; } return false; } public static boolean conflictingSignature(Member m1, Member m2) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return conflictingSignature(m1,m2,true); } /** * Do the two members conflict? Due to the change in 1.7.1, field itds on interfaces now act like 'default' fields - so types implementing * those fields get the field if they don't have it already, otherwise they keep what they have. The conflict detection below had to be * altered. Previously (<1.7.1) it is not a conflict if the declaring types are different. With v2itds it may still be a conflict if the * declaring types are different. */ public static boolean conflictingSignature(Member m1, Member m2, boolean v2itds) { if (m1 == null || m2 == null) { return false; } if (!m1.getName().equals(m2.getName())) { return false; } if (m1.getKind() != m2.getKind()) { return false; } if (m1.getKind() == Member.FIELD) { if (v2itds) { if (m1.getDeclaringType().equals(m2.getDeclaringType())) { return true; } } else { return m1.getDeclaringType().equals(m2.getDeclaringType()); } } else if (m1.getKind() == Member.POINTCUT) { return true; } UnresolvedType[] p1 = m1.getGenericParameterTypes();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
UnresolvedType[] p2 = m2.getGenericParameterTypes(); if (p1 == null) { p1 = m1.getParameterTypes(); } if (p2 == null) { p2 = m2.getParameterTypes(); } int n = p1.length; if (n != p2.length) { return false; } for (int i = 0; i < n; i++) { if (!p1[i].equals(p2[i])) { return false; } } return true; } /** * returns an iterator through all of the pointcuts of this type, in order for checking from JVM spec 2ed 5.4.3.2 (as for * fields). This means that the order is * <p/> * <ul> * <li>pointcuts from current class</li> * <li>recur into direct superinterfaces</li> * <li>recur into superclass</li> * </ul> * <p/> * We keep a hashSet of interfaces that we've visited so we don't spiral out into 2^n land. */
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public Iterator<ResolvedMember> getPointcuts() { final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { public Iterator<ResolvedType> get(ResolvedType o) { return dupFilter.filter(o.getDirectSupertypes()); } }; return Iterators.mapOver(Iterators.recur(this, typeGetter), PointcutGetterInstance); } public ResolvedPointcutDefinition findPointcut(String name) { for (Iterator<ResolvedMember> i = getPointcuts(); i.hasNext();) { ResolvedPointcutDefinition f = (ResolvedPointcutDefinition) i.next(); if (f != null && name.equals(f.getName())) { return f; } } if (!getOutermostType().equals(this)) { ResolvedType outerType = getOutermostType().resolve(world); ResolvedPointcutDefinition rpd = outerType.findPointcut(name); return rpd; } return null; } public CrosscuttingMembers crosscuttingMembers; public CrosscuttingMembers collectCrosscuttingMembers(boolean shouldConcretizeIfNeeded) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
crosscuttingMembers = new CrosscuttingMembers(this, shouldConcretizeIfNeeded); if (getPerClause() == null) { return crosscuttingMembers; } crosscuttingMembers.setPerClause(getPerClause()); crosscuttingMembers.addShadowMungers(collectShadowMungers()); crosscuttingMembers.addTypeMungers(getTypeMungers()); crosscuttingMembers.addDeclares(collectDeclares(!this.doesNotExposeShadowMungers())); crosscuttingMembers.addPrivilegedAccesses(getPrivilegedAccesses()); return crosscuttingMembers; } public final List<Declare> collectDeclares(boolean includeAdviceLike) { if (!this.isAspect()) { return Collections.emptyList(); } List<Declare> ret = new ArrayList<Declare>(); if (!this.isAbstract()) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { public Iterator<ResolvedType> get(ResolvedType o) { return dupFilter.filter((o).getDirectSupertypes()); } }; Iterator<ResolvedType> typeIterator = Iterators.recur(this, typeGetter); while (typeIterator.hasNext()) { ResolvedType ty = typeIterator.next(); for (Iterator<Declare> i = ty.getDeclares().iterator(); i.hasNext();) { Declare dec = i.next(); if (dec.isAdviceLike()) { if (includeAdviceLike) { ret.add(dec); } } else { ret.add(dec); } } } } return ret; } private final List<ShadowMunger> collectShadowMungers() { if (!this.isAspect() || this.isAbstract() || this.doesNotExposeShadowMungers()) { return Collections.emptyList(); } List<ShadowMunger> acc = new ArrayList<ShadowMunger>();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
final Iterators.Filter<ResolvedType> dupFilter = Iterators.dupFilter(); Iterators.Getter<ResolvedType, ResolvedType> typeGetter = new Iterators.Getter<ResolvedType, ResolvedType>() { public Iterator<ResolvedType> get(ResolvedType o) { return dupFilter.filter((o).getDirectSupertypes()); } }; Iterator<ResolvedType> typeIterator = Iterators.recur(this, typeGetter); while (typeIterator.hasNext()) { ResolvedType ty = typeIterator.next(); acc.addAll(ty.getDeclaredShadowMungers()); } return acc; } public void addParent(ResolvedType newParent) { } protected boolean doesNotExposeShadowMungers() { return false; } public PerClause getPerClause() { return null; } public Collection<Declare> getDeclares() { return Collections.emptyList(); } public Collection<ConcreteTypeMunger> getTypeMungers() { return Collections.emptyList(); } public Collection<ResolvedMember> getPrivilegedAccesses() { return Collections.emptyList();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} public final boolean isInterface() { return Modifier.isInterface(getModifiers()); } public final boolean isAbstract() { return Modifier.isAbstract(getModifiers()); } public boolean isClass() { return false; } public boolean isAspect() { return false; } public boolean isAnnotationStyleAspect() { return false; } /** * Note: Only overridden by Name subtype. */ public boolean isEnum() { return false; } /** * Note: Only overridden by Name subtype. */ public boolean isAnnotation() { return false; } public boolean isAnonymous() {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return false; } public boolean isNested() { return false; } public void addAnnotation(AnnotationAJ annotationX) { throw new RuntimeException("ResolvedType.addAnnotation() should never be called"); } public AnnotationAJ[] getAnnotations() { throw new RuntimeException("ResolvedType.getAnnotations() should never be called"); } /** * Note: Only overridden by ReferenceType subtype */ public boolean canAnnotationTargetType() { return false; } /** * Note: Only overridden by ReferenceType subtype */ public AnnotationTargetKind[] getAnnotationTargetKinds() { return null; } /** * Note: Only overridden by Name subtype. */ public boolean isAnnotationWithRuntimeRetention() { return false; } public boolean isSynthetic() {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return signature.indexOf("$ajc") != -1; } public final boolean isFinal() { return Modifier.isFinal(getModifiers()); } protected Map<String, UnresolvedType> getMemberParameterizationMap() { if (!isParameterizedType()) { return Collections.emptyMap(); } TypeVariable[] tvs = getGenericType().getTypeVariables(); Map<String, UnresolvedType> parameterizationMap = new HashMap<String, UnresolvedType>(); for (int i = 0; i < tvs.length; i++) { parameterizationMap.put(tvs[i].getName(), typeParameters[i]); } return parameterizationMap; } public List<ShadowMunger> getDeclaredAdvice() { List<ShadowMunger> l = new ArrayList<ShadowMunger>(); ResolvedMember[] methods = getDeclaredMethods(); if (isParameterizedType()) { methods = getGenericType().getDeclaredMethods(); } Map<String, UnresolvedType> typeVariableMap = getAjMemberParameterizationMap(); for (int i = 0, len = methods.length; i < len; i++) { ShadowMunger munger = methods[i].getAssociatedShadowMunger(); if (munger != null) { if (ajMembersNeedParameterization()) { munger = munger.parameterizeWith(this, typeVariableMap);
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (munger instanceof Advice) { Advice advice = (Advice) munger; UnresolvedType[] ptypes = methods[i].getGenericParameterTypes(); UnresolvedType[] newPTypes = new UnresolvedType[ptypes.length]; for (int j = 0; j < ptypes.length; j++) { if (ptypes[j] instanceof TypeVariableReferenceType) { TypeVariableReferenceType tvrt = (TypeVariableReferenceType) ptypes[j]; if (typeVariableMap.containsKey(tvrt.getTypeVariable().getName())) { newPTypes[j] = typeVariableMap.get(tvrt.getTypeVariable().getName()); } else { newPTypes[j] = ptypes[j]; } } else { newPTypes[j] = ptypes[j]; } } advice.setBindingParameterTypes(newPTypes); } } munger.setDeclaringType(this); l.add(munger); } } return l; } public List<ShadowMunger> getDeclaredShadowMungers() { return getDeclaredAdvice(); }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public ResolvedMember[] getDeclaredJavaFields() { return filterInJavaVisible(getDeclaredFields()); } public ResolvedMember[] getDeclaredJavaMethods() { return filterInJavaVisible(getDeclaredMethods()); } private ResolvedMember[] filterInJavaVisible(ResolvedMember[] ms) { List<ResolvedMember> l = new ArrayList<ResolvedMember>(); for (int i = 0, len = ms.length; i < len; i++) { if (!ms[i].isAjSynthetic() && ms[i].getAssociatedShadowMunger() == null) { l.add(ms[i]); } } return l.toArray(new ResolvedMember[l.size()]); } public abstract ISourceContext getSourceContext(); public static final ResolvedType[] NONE = new ResolvedType[0]; public static final ResolvedType[] EMPTY_ARRAY = NONE; public static final Missing MISSING = new Missing(); public static ResolvedType makeArray(ResolvedType type, int dim) { if (dim == 0) { return type; } ResolvedType array = new ArrayReferenceType("[" + type.getSignature(), "[" + type.getErasureSignature(), type.getWorld(), type); return makeArray(array, dim - 1); } static class Primitive extends ResolvedType {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
private final int size; private final int index; Primitive(String signature, int size, int index) { super(signature, null); this.size = size; this.index = index; this.typeKind = TypeKind.PRIMITIVE; } @Override public final int getSize() { return size; } @Override public final int getModifiers() { return Modifier.PUBLIC | Modifier.FINAL; } @Override public final boolean isPrimitiveType() { return true; } public boolean hasAnnotation(UnresolvedType ofType) { return false; } @Override public final boolean isAssignableFrom(ResolvedType other) { if (!other.isPrimitiveType()) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (!world.isInJava5Mode()) { return false; } return validBoxing.contains(this.getSignature() + other.getSignature()); } return assignTable[((Primitive) other).index][index]; } @Override public final boolean isAssignableFrom(ResolvedType other, boolean allowMissing) { return isAssignableFrom(other); } @Override public final boolean isCoerceableFrom(ResolvedType other) { if (this == other) { return true; } if (!other.isPrimitiveType()) { return false; } if (index > 6 || ((Primitive) other).index > 6) { return false; } return true; } @Override public ResolvedType resolve(World world) { if (this.world != world) { throw new IllegalStateException(); } this.world = world;
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return super.resolve(world); } @Override public final boolean needsNoConversionFrom(ResolvedType other) { if (!other.isPrimitiveType()) { return false; } return noConvertTable[((Primitive) other).index][index]; } private static final boolean[][] assignTable = { { true, true, true, true, true, true, true, false, false }, { false, true, true, true, true, true, false, false, false }, { false, false, true, false, false, false, false, false, false }, { false, false, true, true, false, false, false, false, false }, { false, false, true, true, true, true, false, false, false }, { false, false, true, true, false, true, false, false, false }, { false, false, true, true, true, true, true, false, false }, { false, false, false, false, false, false, false, true, false }, { false, false, false, false, false, false, false, false, true }, }; private static final boolean[][] noConvertTable = { { true, true, false, false, true, false, true, false, false }, { false, true, false, false, true, false, false, false, false }, { false, false, true, false, false, false, false, false, false }, { false, false, false, true, false, false, false, false, false }, { false, false, false, false, true, false, false, false, false }, { false, false, false, false, false, true, false, false, false }, { false, false, false, false, true, false, true, false, false },
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
{ false, false, false, false, false, false, false, true, false }, { false, false, false, false, false, false, false, false, true }, }; @Override public final ResolvedMember[] getDeclaredFields() { return ResolvedMember.NONE; } @Override public final ResolvedMember[] getDeclaredMethods() { return ResolvedMember.NONE; } @Override public final ResolvedType[] getDeclaredInterfaces() { return ResolvedType.NONE; } @Override public final ResolvedMember[] getDeclaredPointcuts() { return ResolvedMember.NONE; } @Override public final ResolvedType getSuperclass() { return null; } @Override public ISourceContext getSourceContext() { return null; } } static class Missing extends ResolvedType {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
Missing() { super(MISSING_NAME, null); } @Override public final String getName() { return MISSING_NAME; } @Override public final boolean isMissing() {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return true; } public boolean hasAnnotation(UnresolvedType ofType) { return false; } @Override public final ResolvedMember[] getDeclaredFields() { return ResolvedMember.NONE; } @Override public final ResolvedMember[] getDeclaredMethods() { return ResolvedMember.NONE; } @Override public final ResolvedType[] getDeclaredInterfaces() { return ResolvedType.NONE; } @Override public final ResolvedMember[] getDeclaredPointcuts() { return ResolvedMember.NONE; } @Override public final ResolvedType getSuperclass() { return null; } @Override public final int getModifiers() { return 0; } @Override
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public final boolean isAssignableFrom(ResolvedType other) { return false; } @Override public final boolean isAssignableFrom(ResolvedType other, boolean allowMissing) { return false; } @Override public final boolean isCoerceableFrom(ResolvedType other) { return false; } @Override public boolean needsNoConversionFrom(ResolvedType other) { return false; } @Override public ISourceContext getSourceContext() { return null; } } /** * Look up a member, takes into account any ITDs on this type. return null if not found */ public ResolvedMember lookupMemberNoSupers(Member member) { ResolvedMember ret = lookupDirectlyDeclaredMemberNoSupers(member); if (ret == null && interTypeMungers != null) { for (ConcreteTypeMunger tm : interTypeMungers) { if (matches(tm.getSignature(), member)) { return tm.getSignature(); }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} } return ret; } public ResolvedMember lookupMemberWithSupersAndITDs(Member member) { ResolvedMember ret = lookupMemberNoSupers(member); if (ret != null) { return ret; } ResolvedType supert = getSuperclass(); while (ret == null && supert != null) { ret = supert.lookupMemberNoSupers(member); if (ret == null) { supert = supert.getSuperclass(); } } return ret; } /** * as lookupMemberNoSupers, but does not include ITDs * * @param member * @return */ public ResolvedMember lookupDirectlyDeclaredMemberNoSupers(Member member) { ResolvedMember ret; if (member.getKind() == Member.FIELD) { ret = lookupMember(member, getDeclaredFields()); } else {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
ret = lookupMember(member, getDeclaredMethods()); } return ret; } /** * This lookup has specialized behaviour - a null result tells the EclipseTypeMunger that it should make a default * implementation of a method on this type. * * @param member * @return */ public ResolvedMember lookupMemberIncludingITDsOnInterfaces(Member member) { return lookupMemberIncludingITDsOnInterfaces(member, this); } private ResolvedMember lookupMemberIncludingITDsOnInterfaces(Member member, ResolvedType onType) { ResolvedMember ret = onType.lookupMemberNoSupers(member); if (ret != null) { return ret; } else { ResolvedType superType = onType.getSuperclass(); if (superType != null) { ret = lookupMemberIncludingITDsOnInterfaces(member, superType); } if (ret == null) { ResolvedType[] superInterfaces = onType.getDeclaredInterfaces(); for (int i = 0; i < superInterfaces.length; i++) { ret = superInterfaces[i].lookupMethodInITDs(member); if (ret != null) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return ret; } } } } return ret; } protected List<ConcreteTypeMunger> interTypeMungers = new ArrayList<ConcreteTypeMunger>(); public List<ConcreteTypeMunger> getInterTypeMungers() { return interTypeMungers; } public List<ConcreteTypeMunger> getInterTypeParentMungers() { List<ConcreteTypeMunger> l = new ArrayList<ConcreteTypeMunger>(); for (ConcreteTypeMunger element : interTypeMungers) { if (element.getMunger() instanceof NewParentTypeMunger) { l.add(element); } } return l; } /** * ??? This method is O(N*M) where N = number of methods and M is number of inter-type declarations in my super */ public List<ConcreteTypeMunger> getInterTypeMungersIncludingSupers() { ArrayList<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>(); collectInterTypeMungers(ret); return ret; } public List<ConcreteTypeMunger> getInterTypeParentMungersIncludingSupers() { ArrayList<ConcreteTypeMunger> ret = new ArrayList<ConcreteTypeMunger>();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
collectInterTypeParentMungers(ret); return ret; } private void collectInterTypeParentMungers(List<ConcreteTypeMunger> collector) { for (Iterator<ResolvedType> iter = getDirectSupertypes(); iter.hasNext();) { ResolvedType superType = iter.next(); superType.collectInterTypeParentMungers(collector); } collector.addAll(getInterTypeParentMungers()); } protected void collectInterTypeMungers(List<ConcreteTypeMunger> collector) { for (Iterator<ResolvedType> iter = getDirectSupertypes(); iter.hasNext();) { ResolvedType superType = iter.next(); if (superType == null) { throw new BCException("UnexpectedProblem: a supertype in the hierarchy for " + this.getName() + " is null"); } superType.collectInterTypeMungers(collector); } outer: for (Iterator<ConcreteTypeMunger> iter1 = collector.iterator(); iter1.hasNext();) { ConcreteTypeMunger superMunger = iter1.next(); if (superMunger.getSignature() == null) { continue; } if (!superMunger.getSignature().isAbstract()) { continue; } for (ConcreteTypeMunger myMunger : getInterTypeMungers()) { if (conflictingSignature(myMunger.getSignature(), superMunger.getSignature())) { iter1.remove(); continue outer;
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} } if (!superMunger.getSignature().isPublic()) { continue; } for (Iterator<ResolvedMember> iter = getMethods(true, true); iter.hasNext();) { ResolvedMember method = iter.next(); if (conflictingSignature(method, superMunger.getSignature())) { iter1.remove(); continue outer; } } } collector.addAll(getInterTypeMungers()); } /** * Check: 1) That we don't have any abstract type mungers unless this type is abstract. 2) That an abstract ITDM on an interface * is declared public. (Compiler limitation) (PR70794) */ public void checkInterTypeMungers() { if (isAbstract()) { return; } boolean itdProblem = false; for (ConcreteTypeMunger munger : getInterTypeMungersIncludingSupers()) { itdProblem = checkAbstractDeclaration(munger) || itdProblem; } if (itdProblem) { return; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
for (ConcreteTypeMunger munger : getInterTypeMungersIncludingSupers()) { if (munger.getSignature() != null && munger.getSignature().isAbstract() && munger.getMunger().getKind()!=ResolvedTypeMunger.PrivilegedAccess) { if (munger.getMunger().getKind() == ResolvedTypeMunger.MethodDelegate2) { } else { world.getMessageHandler() .handleMessage( new Message("must implement abstract inter-type declaration: " + munger.getSignature(), "", IMessage.ERROR, getSourceLocation(), null, new ISourceLocation[] { getMungerLocation(munger) })); } } } } /** * See PR70794. This method checks that if an abstract inter-type method declaration is made on an interface then it must also * be public. This is a compiler limitation that could be made to work in the future (if someone provides a worthwhile usecase) * * @return indicates if the munger failed the check */ private boolean checkAbstractDeclaration(ConcreteTypeMunger munger) { if (munger.getMunger() != null && (munger.getMunger() instanceof NewMethodTypeMunger)) { ResolvedMember itdMember = munger.getSignature(); ResolvedType onType = itdMember.getDeclaringType().resolve(world); if (onType.isInterface() && itdMember.isAbstract() && !itdMember.isPublic()) { world.getMessageHandler().handleMessage( new Message(WeaverMessages.format(WeaverMessages.ITD_ABSTRACT_MUST_BE_PUBLIC_ON_INTERFACE, munger.getSignature(), onType), "", Message.ERROR, getSourceLocation(), null, new ISourceLocation[] { getMungerLocation(munger) }));
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return true; } } return false; } /** * Get a source location for the munger. Until intertype mungers remember where they came from, the source location for the * munger itself is null. In these cases use the source location for the aspect containing the ITD. */ private ISourceLocation getMungerLocation(ConcreteTypeMunger munger) { ISourceLocation sloc = munger.getSourceLocation(); if (sloc == null) { sloc = munger.getAspectType().getSourceLocation(); } return sloc; } /** * Returns a ResolvedType object representing the declaring type of this type, or null if this type does not represent a * non-package-level-type. * <p/> * <strong>Warning</strong>: This is guaranteed to work for all member types. For anonymous/local types, the only guarantee is * given in JLS 13.1, where it guarantees that if you call getDeclaringType() repeatedly, you will eventually get the top-level * class, but it does not say anything about classes in between. * * @return the declaring UnresolvedType object, or null. */ public ResolvedType getDeclaringType() { if (isArray()) { return null; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
String name = getName(); int lastDollar = name.lastIndexOf('$'); while (lastDollar > 0) { ResolvedType ret = world.resolve(UnresolvedType.forName(name.substring(0, lastDollar)), true); if (!ResolvedType.isMissing(ret)) { return ret; } lastDollar = name.lastIndexOf('$', lastDollar - 1); } return null; } public static boolean isVisible(int modifiers, ResolvedType targetType, ResolvedType fromType) { if (Modifier.isPublic(modifiers)) { return true; } else if (Modifier.isPrivate(modifiers)) { return targetType.getOutermostType().equals(fromType.getOutermostType()); } else if (Modifier.isProtected(modifiers)) { return samePackage(targetType, fromType) || targetType.isAssignableFrom(fromType); } else { return samePackage(targetType, fromType); } } private static boolean samePackage(ResolvedType targetType, ResolvedType fromType) { String p1 = targetType.getPackageName(); String p2 = fromType.getPackageName(); if (p1 == null) { return p2 == null; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (p2 == null) { return false; } return p1.equals(p2); } /** * Checks if the generic type for 'this' and the generic type for 'other' are the same - it can be passed raw or parameterized * versions and will just compare the underlying generic type. */ private boolean genericTypeEquals(ResolvedType other) { ResolvedType rt = other; if (rt.isParameterizedType() || rt.isRawType()) { rt.getGenericType(); } if (((isParameterizedType() || isRawType()) && getGenericType().equals(rt)) || (this.equals(other))) { return true; } return false; } /** * Look up the actual occurence of a particular type in the hierarchy for 'this' type. The input is going to be a generic type, * and the caller wants to know if it was used in its RAW or a PARAMETERIZED form in this hierarchy. * * returns null if it can't be found. */ public ResolvedType discoverActualOccurrenceOfTypeInHierarchy(ResolvedType lookingFor) { if (!lookingFor.isGenericType()) { throw new BCException("assertion failed: method should only be called with generic type, but " + lookingFor + " is " + lookingFor.typeKind); }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (this.equals(ResolvedType.OBJECT)) { return null; } if (genericTypeEquals(lookingFor)) { return this; } ResolvedType superT = getSuperclass(); if (superT.genericTypeEquals(lookingFor)) { return superT; } ResolvedType[] superIs = getDeclaredInterfaces(); for (int i = 0; i < superIs.length; i++) { ResolvedType superI = superIs[i]; if (superI.genericTypeEquals(lookingFor)) { return superI; } ResolvedType checkTheSuperI = superI.discoverActualOccurrenceOfTypeInHierarchy(lookingFor); if (checkTheSuperI != null) { return checkTheSuperI; } } return superT.discoverActualOccurrenceOfTypeInHierarchy(lookingFor); } /** * Called for all type mungers but only does something if they share type variables with a generic type which they target. When * this happens this routine will check for the target type in the target hierarchy and 'bind' any type parameters as * appropriate. For example, for the ITD "List<T> I<T>.x" against a type like this: "class A implements I<String>" this routine * will return a parameterized form of the ITD "List<String> I.x" */ public ConcreteTypeMunger fillInAnyTypeParameters(ConcreteTypeMunger munger) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
boolean debug = false; ResolvedMember member = munger.getSignature(); if (munger.isTargetTypeParameterized()) { if (debug) { System.err.println("Processing attempted parameterization of " + munger + " targetting type " + this); } if (debug) { System.err.println(" This type is " + this + " (" + typeKind + ")"); } if (debug) { System.err.println(" Signature that needs parameterizing: " + member); } ResolvedType onTypeResolved = world.resolve(member.getDeclaringType()); ResolvedType onType = onTypeResolved.getGenericType(); if (onType == null) { getWorld().getMessageHandler().handleMessage( MessageUtil.error("The target type for the intertype declaration is not generic", munger.getSourceLocation())); return munger; } member.resolve(world); if (debug) { System.err.println(" Actual target ontype: " + onType + " (" + onType.typeKind + ")"); } ResolvedType actualTarget = discoverActualOccurrenceOfTypeInHierarchy(onType);
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (actualTarget == null) { throw new BCException("assertion failed: asked " + this + " for occurrence of " + onType + " in its hierarchy??"); } if (!actualTarget.isGenericType()) { if (debug) { System.err.println("Occurrence in " + this + " is actually " + actualTarget + " (" + actualTarget.typeKind + ")"); } } munger = munger.parameterizedFor(actualTarget); if (debug) { System.err.println("New sig: " + munger.getSignature()); } if (debug) { System.err.println("====================================="); } } return munger; } /** * Add an intertype munger to this type. isDuringCompilation tells us if we should be checking for an error scenario where two * ITD fields are trying to use the same name. When this happens during compilation one of them is altered to get mangled name
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* but when it happens during weaving it is too late and we need to put out an error asking them to recompile. */ public void addInterTypeMunger(ConcreteTypeMunger munger, boolean isDuringCompilation) { ResolvedMember sig = munger.getSignature(); bits = (bits & ~MungersAnalyzed); if (sig == null || munger.getMunger() == null || munger.getMunger().getKind() == ResolvedTypeMunger.PrivilegedAccess) { interTypeMungers.add(munger); return; } munger = fillInAnyTypeParameters(munger); sig = munger.getSignature(); if (sig.getKind() == Member.METHOD) { if (clashesWithExistingMember(munger, getMethods(true, false))) { return; } if (this.isInterface()) { if (clashesWithExistingMember(munger, Arrays.asList(world.getCoreType(OBJECT).getDeclaredMethods()).iterator())) { return; } }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
} else if (sig.getKind() == Member.FIELD) { if (clashesWithExistingMember(munger, Arrays.asList(getDeclaredFields()).iterator())) { return; } if (!isDuringCompilation) { ResolvedTypeMunger thisRealMunger = munger.getMunger(); if (thisRealMunger instanceof NewFieldTypeMunger) { NewFieldTypeMunger newFieldTypeMunger = (NewFieldTypeMunger) thisRealMunger; if (newFieldTypeMunger.version == NewFieldTypeMunger.VersionTwo) { String thisRealMungerSignatureName = newFieldTypeMunger.getSignature().getName(); for (ConcreteTypeMunger typeMunger : interTypeMungers) { if (typeMunger.getMunger() instanceof NewFieldTypeMunger) { if (typeMunger.getSignature().getKind() == Member.FIELD) { NewFieldTypeMunger existing = (NewFieldTypeMunger) typeMunger.getMunger(); if (existing.getSignature().getName().equals(thisRealMungerSignatureName) && existing.version == NewFieldTypeMunger.VersionTwo && existing.getSignature().getDeclaringType() .equals(newFieldTypeMunger.getSignature().getDeclaringType())) { StringBuffer sb = new StringBuffer(); sb.append("Cannot handle two aspects both attempting to use new style ITDs for the same named field "); sb.append("on the same target type. Please recompile at least one aspect with '-Xset:itdVersion=1'."); sb.append(" Aspects involved: " + munger.getAspectType().getName() + " and " + typeMunger.getAspectType().getName() + "."); sb.append(" Field is named '" + existing.getSignature().getName() + "'"); getWorld().getMessageHandler().handleMessage(
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
new Message(sb.toString(), getSourceLocation(), true)); return; } } } } } } } } else { if (clashesWithExistingMember(munger, Arrays.asList(getDeclaredMethods()).iterator())) { return; } } boolean needsAdding =true; boolean needsToBeAddedEarlier =false; for (Iterator<ConcreteTypeMunger> i = interTypeMungers.iterator(); i.hasNext();) { ConcreteTypeMunger existingMunger = i.next(); boolean v2itds = munger.getSignature().getKind()== Member.FIELD && (munger.getMunger() instanceof NewFieldTypeMunger) && ((NewFieldTypeMunger)munger.getMunger()).version==NewFieldTypeMunger.VersionTwo; if (conflictingSignature(existingMunger.getSignature(), munger.getSignature(),v2itds)) { if (isVisible(munger.getSignature().getModifiers(), munger.getAspectType(), existingMunger.getAspectType())) { int c = compareMemberPrecedence(sig, existingMunger.getSignature()); if (c == 0) { c = getWorld().compareByPrecedenceAndHierarchy(munger.getAspectType(), existingMunger.getAspectType()); } if (c < 0) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
checkLegalOverride(munger.getSignature(), existingMunger.getSignature(), 0x11, null); needsAdding = false; if (munger.getSignature().getKind()== Member.FIELD && munger.getSignature().getDeclaringType().resolve(world).isInterface() && ((NewFieldTypeMunger)munger.getMunger()).version==NewFieldTypeMunger.VersionTwo) { needsAdding=true; } break; } else if (c > 0) { checkLegalOverride(existingMunger.getSignature(), munger.getSignature(), 0x11, null); if (existingMunger.getSignature().getKind()==Member.FIELD && existingMunger.getSignature().getDeclaringType().resolve(world).isInterface() && ((NewFieldTypeMunger)existingMunger.getMunger()).version==NewFieldTypeMunger.VersionTwo) { needsToBeAddedEarlier=true; } else { i.remove(); } break; } else { interTypeConflictError(munger, existingMunger); interTypeConflictError(existingMunger, munger); return; } } } }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (needsAdding) { if (!needsToBeAddedEarlier) { interTypeMungers.add(munger); } else { interTypeMungers.add(0,munger); } } } /** * Compare the type transformer with the existing members. A clash may not be an error (the ITD may be the 'default * implementation') so returning false is not always a sign of an error. * * @return true if there is a clash */ private boolean clashesWithExistingMember(ConcreteTypeMunger typeTransformer, Iterator<ResolvedMember> existingMembers) { ResolvedMember typeTransformerSignature = typeTransformer.getSignature();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
ResolvedTypeMunger rtm = typeTransformer.getMunger(); boolean v2itds = true; if (rtm instanceof NewFieldTypeMunger && ((NewFieldTypeMunger)rtm).version==NewFieldTypeMunger.VersionOne) { v2itds = false; } while (existingMembers.hasNext()) { ResolvedMember existingMember = existingMembers.next(); if (existingMember.isBridgeMethod()) { continue; } if (conflictingSignature(existingMember, typeTransformerSignature,v2itds)) { if (isVisible(existingMember.getModifiers(), this, typeTransformer.getAspectType())) { int c = compareMemberPrecedence(typeTransformerSignature, existingMember); if (c < 0) { ResolvedType typeTransformerTargetType = typeTransformerSignature.getDeclaringType().resolve(world);
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (typeTransformerTargetType.isInterface()) { ResolvedType existingMemberType = existingMember.getDeclaringType().resolve(world); if ((rtm instanceof NewMethodTypeMunger) && !typeTransformerTargetType.equals(existingMemberType)) { if (Modifier.isPrivate(typeTransformerSignature.getModifiers()) && Modifier.isPublic(existingMember.getModifiers())) { world.getMessageHandler().handleMessage(new Message("private intertype declaration '"+typeTransformerSignature.toString()+"' clashes with public member '"+existingMember.toString()+"'",existingMember.getSourceLocation(),true)); } } } checkLegalOverride(typeTransformerSignature, existingMember, 0x10, typeTransformer.getAspectType()); return true; } else if (c > 0) { checkLegalOverride(existingMember, typeTransformerSignature, 0x01, typeTransformer.getAspectType()); continue; } else { boolean sameReturnTypes = (existingMember.getReturnType().equals(typeTransformerSignature.getReturnType())); if (sameReturnTypes) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
boolean isDuplicateOfPreviousITD = false; ResolvedType declaringRt = existingMember.getDeclaringType().resolve(world); WeaverStateInfo wsi = declaringRt.getWeaverState(); if (wsi != null) { List<ConcreteTypeMunger> mungersAffectingThisType = wsi.getTypeMungers(declaringRt); if (mungersAffectingThisType != null) { for (Iterator<ConcreteTypeMunger> iterator = mungersAffectingThisType.iterator(); iterator .hasNext() && !isDuplicateOfPreviousITD;) { ConcreteTypeMunger ctMunger = iterator.next(); if (ctMunger.getSignature().equals(existingMember) && ctMunger.aspectType.equals(typeTransformer.getAspectType())) { isDuplicateOfPreviousITD = true; } } } } if (!isDuplicateOfPreviousITD) { if (!(typeTransformerSignature.getName().equals("<init>") && existingMember.isDefaultConstructor())) { String aspectName = typeTransformer.getAspectType().getName(); ISourceLocation typeTransformerLocation = typeTransformer.getSourceLocation(); ISourceLocation existingMemberLocation = existingMember.getSourceLocation(); String msg = WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT, aspectName,
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
existingMember); getWorld().getMessageHandler().handleMessage(new Message(msg, typeTransformerLocation, true)); if (existingMemberLocation != null) { getWorld().getMessageHandler() .handleMessage(new Message(msg, existingMemberLocation, true)); } return true; } } } } } else if (isDuplicateMemberWithinTargetType(existingMember, this, typeTransformerSignature)) { getWorld().getMessageHandler().handleMessage( MessageUtil.error(WeaverMessages.format(WeaverMessages.ITD_MEMBER_CONFLICT, typeTransformer .getAspectType().getName(), existingMember), typeTransformer.getSourceLocation())); return true; } } } return false; }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
private boolean isDuplicateMemberWithinTargetType(ResolvedMember existingMember, ResolvedType targetType, ResolvedMember itdMember) { if ((existingMember.isAbstract() || itdMember.isAbstract())) { return false; } UnresolvedType declaringType = existingMember.getDeclaringType(); if (!targetType.equals(declaringType)) { return false; } if (Modifier.isPrivate(itdMember.getModifiers())) { return false; } if (itdMember.isPublic()) { return true; } if (!targetType.getPackageName().equals(itdMember.getDeclaringType().getPackageName())) { return false; } return true; } /** * @param transformerPosition which parameter is the type transformer (0x10 for first, 0x01 for second, 0x11 for both, 0x00 for * neither) * @param aspectType the declaring type of aspect defining the *first* type transformer * @return true if the override is legal note: calling showMessage with two locations issues TWO messages, not ONE message with
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
* an additional source location. */ public boolean checkLegalOverride(ResolvedMember parent, ResolvedMember child, int transformerPosition, ResolvedType aspectType) { if (Modifier.isFinal(parent.getModifiers())) { if (transformerPosition == 0x10 && aspectType != null) { ResolvedType nonItdDeclaringType = child.getDeclaringType().resolve(world); WeaverStateInfo wsi = nonItdDeclaringType.getWeaverState(); if (wsi != null) { List<ConcreteTypeMunger> transformersOnThisType = wsi.getTypeMungers(nonItdDeclaringType); if (transformersOnThisType != null) { for (ConcreteTypeMunger transformer : transformersOnThisType) { if (transformer.aspectType.equals(aspectType)) { if (parent.equalsApartFromDeclaringType(transformer.getSignature())) { return true; } } } } } } world.showMessage(Message.ERROR, WeaverMessages.format(WeaverMessages.CANT_OVERRIDE_FINAL_MEMBER, parent), child.getSourceLocation(), null);
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return false; } boolean incompatibleReturnTypes = false; if (world.isInJava5Mode() && parent.getKind() == Member.METHOD) { ResolvedType rtParentReturnType = parent.resolve(world).getGenericReturnType().resolve(world); ResolvedType rtChildReturnType = child.resolve(world).getGenericReturnType().resolve(world); incompatibleReturnTypes = !rtParentReturnType.isAssignableFrom(rtChildReturnType); } else { ResolvedType rtParentReturnType = parent.resolve(world).getGenericReturnType().resolve(world); ResolvedType rtChildReturnType = child.resolve(world).getGenericReturnType().resolve(world); incompatibleReturnTypes = !rtParentReturnType.equals(rtChildReturnType); } if (incompatibleReturnTypes) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_RETURN_TYPE_MISMATCH, parent, child), child.getSourceLocation(), parent.getSourceLocation()); return false; } if (parent.getKind() == Member.POINTCUT) { UnresolvedType[] pTypes = parent.getParameterTypes(); UnresolvedType[] cTypes = child.getParameterTypes(); if (!Arrays.equals(pTypes, cTypes)) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_PARAM_TYPE_MISMATCH, parent, child), child.getSourceLocation(), parent.getSourceLocation()); return false; } } if (isMoreVisible(parent.getModifiers(), child.getModifiers())) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_VISIBILITY_REDUCTION, parent, child), child.getSourceLocation(), parent.getSourceLocation()); return false; } ResolvedType[] childExceptions = world.resolve(child.getExceptions()); ResolvedType[] parentExceptions = world.resolve(parent.getExceptions()); ResolvedType runtimeException = world.resolve("java.lang.RuntimeException"); ResolvedType error = world.resolve("java.lang.Error"); outer: for (int i = 0, leni = childExceptions.length; i < leni; i++) { if (runtimeException.isAssignableFrom(childExceptions[i])) { continue; } if (error.isAssignableFrom(childExceptions[i])) { continue; } for (int j = 0, lenj = parentExceptions.length; j < lenj; j++) { if (parentExceptions[j].isAssignableFrom(childExceptions[i])) { continue outer; } }
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return false; } boolean parentStatic = Modifier.isStatic(parent.getModifiers()); boolean childStatic = Modifier.isStatic(child.getModifiers()); if (parentStatic && !childStatic) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_OVERRIDDEN_STATIC, child, parent), child.getSourceLocation(), null); return false; } else if (childStatic && !parentStatic) { world.showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_OVERIDDING_STATIC, child, parent), child.getSourceLocation(), null); return false; } return true; } private int compareMemberPrecedence(ResolvedMember m1, ResolvedMember m2) { if (Modifier.isProtected(m2.getModifiers()) && m2.getName().charAt(0) == 'c') { UnresolvedType declaring = m2.getDeclaringType();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (declaring != null) { if (declaring.getName().equals("java.lang.Object") && m2.getName().equals("clone")) { return +1; } } } if (Modifier.isAbstract(m1.getModifiers())) { return -1; } if (Modifier.isAbstract(m2.getModifiers())) { return +1; } if (m1.getDeclaringType().equals(m2.getDeclaringType())) { return 0; } ResolvedType t1 = m1.getDeclaringType().resolve(world); ResolvedType t2 = m2.getDeclaringType().resolve(world); if (t1.isAssignableFrom(t2)) { return -1; } if (t2.isAssignableFrom(t1)) { return +1; } return 0; } public static boolean isMoreVisible(int m1, int m2) { if (Modifier.isPrivate(m1)) { return false; } if (isPackage(m1)) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
return Modifier.isPrivate(m2); } if (Modifier.isProtected(m1)) { return (Modifier.isPrivate(m2) || isPackage(m2)); } if (Modifier.isPublic(m1)) { return !Modifier.isPublic(m2); } throw new RuntimeException("bad modifier: " + m1); } private static boolean isPackage(int i) { return (0 == (i & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED))); } private void interTypeConflictError(ConcreteTypeMunger m1, ConcreteTypeMunger m2) { /* * if (m1.getMunger().getKind() == ResolvedTypeMunger.Field && m2.getMunger().getKind() == ResolvedTypeMunger.Field) { if * *exactly* the same, it's ok return true; } */ getWorld().showMessage( IMessage.ERROR, WeaverMessages.format(WeaverMessages.ITD_CONFLICT, m1.getAspectType().getName(), m2.getSignature(), m2 .getAspectType().getName()), m2.getSourceLocation(), getSourceLocation()); } public ResolvedMember lookupSyntheticMember(Member member) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
for (ConcreteTypeMunger m : interTypeMungers) { ResolvedMember ret = m.getMatchingSyntheticMember(member); if (ret != null) { return ret; } } if (world.isJoinpointArrayConstructionEnabled() && this.isArray()) { if (member.getKind() == Member.CONSTRUCTOR) { ResolvedMemberImpl ret = new ResolvedMemberImpl(Member.CONSTRUCTOR, this, Modifier.PUBLIC, UnresolvedType.VOID, "<init>", world.resolve(member.getParameterTypes())); int count = ret.getParameterTypes().length; String[] paramNames = new String[count]; for (int i = 0; i < count; i++) { paramNames[i] = new StringBuffer("dim").append(i).toString(); } ret.setParameterNames(paramNames); return ret; } } return null; } static class SuperClassWalker implements Iterator<ResolvedType> {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
private ResolvedType curr; private SuperInterfaceWalker iwalker; private boolean wantGenerics; public SuperClassWalker(ResolvedType type, SuperInterfaceWalker iwalker, boolean genericsAware) { this.curr = type; this.iwalker = iwalker; this.wantGenerics = genericsAware; } public boolean hasNext() { return curr != null; } public ResolvedType next() { ResolvedType ret = curr; if (!wantGenerics && ret.isParameterizedOrGenericType()) { ret = ret.getRawType(); } iwalker.push(ret); curr = curr.getSuperclass(); return ret; } public void remove() { throw new UnsupportedOperationException(); } } static class SuperInterfaceWalker implements Iterator<ResolvedType> { private Getter<ResolvedType, ResolvedType> ifaceGetter; Iterator<ResolvedType> delegate = null; public Queue<ResolvedType> toPersue = new LinkedList<ResolvedType>();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
public Set<ResolvedType> visited = new HashSet<ResolvedType>(); SuperInterfaceWalker(Iterators.Getter<ResolvedType, ResolvedType> ifaceGetter) { this.ifaceGetter = ifaceGetter; } SuperInterfaceWalker(Iterators.Getter<ResolvedType, ResolvedType> ifaceGetter, ResolvedType interfaceType) { this.ifaceGetter = ifaceGetter; this.delegate = Iterators.one(interfaceType); } public boolean hasNext() { if (delegate == null || !delegate.hasNext()) { if (toPersue.isEmpty()) { return false; } do { ResolvedType next = toPersue.remove(); visited.add(next); delegate = ifaceGetter.get(next); } while (!delegate.hasNext() && !toPersue.isEmpty()); } return delegate.hasNext(); } public void push(ResolvedType ret) { toPersue.add(ret); } public ResolvedType next() { ResolvedType next = delegate.next();
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
if (visited.add(next)) { toPersue.add(next); } return next; } public void remove() { throw new UnsupportedOperationException(); } } public void clearInterTypeMungers() { if (isRawType()) { ResolvedType genericType = getGenericType(); if (genericType.isRawType()) { System.err.println("DebugFor341926: Type " + this.getName() + " has an incorrect generic form"); } else { genericType.clearInterTypeMungers(); } } interTypeMungers = new ArrayList<ConcreteTypeMunger>(); } public boolean isTopmostImplementor(ResolvedType interfaceType) { boolean b = true; if (isInterface()) { b = false; } else if (!interfaceType.isAssignableFrom(this, true)) { b = false; } else {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
ResolvedType superclass = this.getSuperclass(); if (superclass.isMissing()) { b = true; } else if (interfaceType.isAssignableFrom(superclass, true)) { b = false; } } return b; } public ResolvedType getTopmostImplementor(ResolvedType interfaceType) { if (isInterface()) { return null; } if (!interfaceType.isAssignableFrom(this)) { return null; } ResolvedType higherType = this.getSuperclass().getTopmostImplementor(interfaceType); if (higherType != null) { return higherType; } return this; } public List<ResolvedMember> getExposedPointcuts() { List<ResolvedMember> ret = new ArrayList<ResolvedMember>(); if (getSuperclass() != null) { ret.addAll(getSuperclass().getExposedPointcuts()); } for (ResolvedType type : getDeclaredInterfaces()) {
404,594
Bug 404594 Assertion failed at ResolvedType.java:614
null
resolved fixed
4e34477
AspectJ
https://github.com/eclipse/org.aspectj
eclipse/org.aspectj
java
null
null
null
2013-04-01T22:29:13Z
2013-03-28T19:46:40Z
org.aspectj.matcher/src/org/aspectj/weaver/ResolvedType.java
addPointcutsResolvingConflicts(ret, Arrays.asList(type.getDeclaredPointcuts()), false); } addPointcutsResolvingConflicts(ret, Arrays.asList(getDeclaredPointcuts()), true); for (ResolvedMember member : ret) { ResolvedPointcutDefinition inherited = (ResolvedPointcutDefinition) member; if (inherited != null && inherited.isAbstract()) { if (!this.isAbstract()) { getWorld().showMessage(IMessage.ERROR, WeaverMessages.format(WeaverMessages.POINCUT_NOT_CONCRETE, inherited, this.getName()), inherited.getSourceLocation(), this.getSourceLocation()); } } } return ret; } private void addPointcutsResolvingConflicts(List<ResolvedMember> acc, List<ResolvedMember> added, boolean isOverriding) { for (Iterator<ResolvedMember> i = added.iterator(); i.hasNext();) { ResolvedPointcutDefinition toAdd = (ResolvedPointcutDefinition) i.next(); for (Iterator<ResolvedMember> j = acc.iterator(); j.hasNext();) { ResolvedPointcutDefinition existing = (ResolvedPointcutDefinition) j.next(); if (toAdd == null || existing == null || existing == toAdd) { continue; } UnresolvedType pointcutDeclaringTypeUT = existing.getDeclaringType(); if (pointcutDeclaringTypeUT != null) { ResolvedType pointcutDeclaringType = pointcutDeclaringTypeUT.resolve(getWorld()); if (!isVisible(existing.getModifiers(), pointcutDeclaringType, this)) { if (existing.isAbstract() && conflictingSignature(existing, toAdd)) {