Lines 26-31
Link Here
|
26 |
import org.aspectj.apache.bcel.classfile.JavaClass; |
26 |
import org.aspectj.apache.bcel.classfile.JavaClass; |
27 |
import org.aspectj.apache.bcel.classfile.Method; |
27 |
import org.aspectj.apache.bcel.classfile.Method; |
28 |
import org.aspectj.apache.bcel.classfile.Signature; |
28 |
import org.aspectj.apache.bcel.classfile.Signature; |
|
|
29 |
import org.aspectj.apache.bcel.classfile.Signature.ClassSignature; |
29 |
import org.aspectj.apache.bcel.classfile.annotation.Annotation; |
30 |
import org.aspectj.apache.bcel.classfile.annotation.Annotation; |
30 |
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; |
31 |
import org.aspectj.apache.bcel.classfile.annotation.ArrayElementValue; |
31 |
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; |
32 |
import org.aspectj.apache.bcel.classfile.annotation.ElementNameValuePair; |
Lines 92-98
Link Here
|
92 |
private String retentionPolicy; |
93 |
private String retentionPolicy; |
93 |
private boolean discoveredAnnotationTargetKinds = false; |
94 |
private boolean discoveredAnnotationTargetKinds = false; |
94 |
private AnnotationTargetKind[] annotationTargetKinds; |
95 |
private AnnotationTargetKind[] annotationTargetKinds; |
95 |
|
96 |
private int modifiers; |
|
|
97 |
private String superclassName; |
98 |
private String className; |
99 |
|
100 |
public void evictReweavingState() { |
101 |
if (javaClass != null) { |
102 |
// force retrieval of any lazy information |
103 |
getDeclaredFields(); |
104 |
getDeclaredInterfaces(); |
105 |
getDeclaredMethods(); |
106 |
getDeclaredPointcuts(); |
107 |
getTypeVariables(); |
108 |
ensureAnnotationTypesRetrieved(); |
109 |
ensureGenericInfoProcessed(); |
110 |
|
111 |
if (weaverState != null) { |
112 |
weaverState.setReweavable(false); |
113 |
weaverState.setUnwovenClassFileData(null); |
114 |
} |
115 |
javaClass = null; |
116 |
for (int i = methods.length - 1; i >= 0; i--) { |
117 |
((BcelMethod)methods[i]).evictMethodHandle(); |
118 |
} |
119 |
} |
120 |
} |
96 |
|
121 |
|
97 |
/** |
122 |
/** |
98 |
* A BcelObjectType is 'damaged' if it has been modified from what was original constructed from |
123 |
* A BcelObjectType is 'damaged' if it has been modified from what was original constructed from |
Lines 100-105
Link Here
|
100 |
* ideally BcelObjectType should be immutable but that's a bigger piece of work!!!!!!!!!! XXX |
125 |
* ideally BcelObjectType should be immutable but that's a bigger piece of work!!!!!!!!!! XXX |
101 |
*/ |
126 |
*/ |
102 |
private boolean damaged = false; |
127 |
private boolean damaged = false; |
|
|
128 |
private boolean isInterface; |
129 |
private boolean isEnum; |
130 |
private boolean isAnnotation; |
131 |
private boolean isAnonymous; |
132 |
private boolean isNested; |
133 |
private ClassSignature cachedGenericClassTypeSignature; |
103 |
|
134 |
|
104 |
public Collection getTypeMungers() { |
135 |
public Collection getTypeMungers() { |
105 |
return typeMungers; |
136 |
return typeMungers; |
Lines 120-125
Link Here
|
120 |
BcelObjectType(ReferenceType resolvedTypeX, JavaClass javaClass, boolean exposedToWeaver) { |
151 |
BcelObjectType(ReferenceType resolvedTypeX, JavaClass javaClass, boolean exposedToWeaver) { |
121 |
super(resolvedTypeX, exposedToWeaver); |
152 |
super(resolvedTypeX, exposedToWeaver); |
122 |
this.javaClass = javaClass; |
153 |
this.javaClass = javaClass; |
|
|
154 |
cacheFromJavaClass(); |
123 |
|
155 |
|
124 |
//ATAJ: set the delegate right now for @AJ pointcut, else it is done too late to lookup |
156 |
//ATAJ: set the delegate right now for @AJ pointcut, else it is done too late to lookup |
125 |
// @AJ pc refs annotation in class hierarchy |
157 |
// @AJ pc refs annotation in class hierarchy |
Lines 143-150
Link Here
|
143 |
public void setJavaClass(JavaClass newclass) { |
175 |
public void setJavaClass(JavaClass newclass) { |
144 |
this.javaClass = newclass; |
176 |
this.javaClass = newclass; |
145 |
resetState(); |
177 |
resetState(); |
|
|
178 |
cacheFromJavaClass(); |
146 |
} |
179 |
} |
147 |
|
180 |
|
|
|
181 |
private void cacheFromJavaClass() { |
182 |
isInterface=javaClass.isInterface(); |
183 |
isEnum=javaClass.isEnum(); |
184 |
isAnnotation=javaClass.isAnnotation(); |
185 |
isAnonymous=javaClass.isAnonymous(); |
186 |
isNested=javaClass.isNested(); |
187 |
modifiers=javaClass.getAccessFlags(); |
188 |
superclassName=javaClass.getSuperclassName(); |
189 |
className=javaClass.getClassName(); |
190 |
cachedGenericClassTypeSignature = javaClass.getGenericClassTypeSignature(); |
191 |
} |
192 |
|
148 |
|
193 |
|
149 |
|
194 |
|
150 |
|
195 |
|
Lines 174-180
Link Here
|
174 |
} |
219 |
} |
175 |
|
220 |
|
176 |
public int getModifiers() { |
221 |
public int getModifiers() { |
177 |
return javaClass.getAccessFlags(); |
222 |
return modifiers; |
178 |
} |
223 |
} |
179 |
|
224 |
|
180 |
/** |
225 |
/** |
Lines 184-190
Link Here
|
184 |
if (isObject) return null; |
229 |
if (isObject) return null; |
185 |
unpackGenericSignature(); |
230 |
unpackGenericSignature(); |
186 |
if (superClass == null) { |
231 |
if (superClass == null) { |
187 |
superClass = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(javaClass.getSuperclassName())); |
232 |
superClass = getResolvedTypeX().getWorld().resolve(UnresolvedType.forName(superclassName)); |
188 |
} |
233 |
} |
189 |
return superClass; |
234 |
return superClass; |
190 |
} |
235 |
} |
Lines 273-279
Link Here
|
273 |
typeMungers = new ArrayList(); |
318 |
typeMungers = new ArrayList(); |
274 |
declares = new ArrayList(); |
319 |
declares = new ArrayList(); |
275 |
// Pass in empty list that can store things for readAj5 to process |
320 |
// Pass in empty list that can store things for readAj5 to process |
276 |
List l = BcelAttributes.readAjAttributes(javaClass.getClassName(),javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler(),AjAttribute.WeaverVersionInfo.UNKNOWN); |
321 |
List l = BcelAttributes.readAjAttributes(className,javaClass.getAttributes(), getResolvedTypeX().getSourceContext(),getResolvedTypeX().getWorld().getMessageHandler(),AjAttribute.WeaverVersionInfo.UNKNOWN); |
277 |
processAttributes(l,pointcuts,false); |
322 |
processAttributes(l,pointcuts,false); |
278 |
l = AtAjAttributes.readAj5ClassAttributes(javaClass, getResolvedTypeX(), getResolvedTypeX().getSourceContext(), getResolvedTypeX().getWorld().getMessageHandler(),isCodeStyleAspect); |
323 |
l = AtAjAttributes.readAj5ClassAttributes(javaClass, getResolvedTypeX(), getResolvedTypeX().getSourceContext(), getResolvedTypeX().getWorld().getMessageHandler(),isCodeStyleAspect); |
279 |
AjAttribute.Aspect deferredAspectAttribute = processAttributes(l,pointcuts,true); |
324 |
AjAttribute.Aspect deferredAspectAttribute = processAttributes(l,pointcuts,true); |
Lines 332-338
Link Here
|
332 |
return perClause; |
377 |
return perClause; |
333 |
} |
378 |
} |
334 |
|
379 |
|
335 |
JavaClass getJavaClass() { |
380 |
public JavaClass getJavaClass() { |
336 |
return javaClass; |
381 |
return javaClass; |
337 |
} |
382 |
} |
338 |
|
383 |
|
Lines 341-346
Link Here
|
341 |
} |
386 |
} |
342 |
|
387 |
|
343 |
public void resetState() { |
388 |
public void resetState() { |
|
|
389 |
if (javaClass == null) { |
390 |
// we might store the classname and allow reloading? |
391 |
// At this point we are relying on the world to not evict if it might want to reweave multiple times |
392 |
throw new BCException("can't reweave evicted type"); |
393 |
} |
344 |
this.interfaces = null; |
394 |
this.interfaces = null; |
345 |
this.superClass = null; |
395 |
this.superClass = null; |
346 |
this.fields = null; |
396 |
this.fields = null; |
Lines 401-407
Link Here
|
401 |
//System.err.println("creating lazy class gen for: " + this); |
451 |
//System.err.println("creating lazy class gen for: " + this); |
402 |
ret = new LazyClassGen(this); |
452 |
ret = new LazyClassGen(this); |
403 |
//ret.print(System.err); |
453 |
//ret.print(System.err); |
404 |
//System.err.println("made LCG from : " + this.getJavaClass().getSuperclassName() ); |
454 |
//System.err.println("made LCG from : " + this.getJavaClass().getSuperclassName ); |
405 |
if (isAspect()) { |
455 |
if (isAspect()) { |
406 |
lazyClassGen = ret; |
456 |
lazyClassGen = ret; |
407 |
} |
457 |
} |
Lines 410-432
Link Here
|
410 |
} |
460 |
} |
411 |
|
461 |
|
412 |
public boolean isInterface() { |
462 |
public boolean isInterface() { |
413 |
return javaClass.isInterface(); |
463 |
return isInterface;//javaClass.isInterface(); |
414 |
} |
464 |
} |
415 |
|
465 |
|
416 |
public boolean isEnum() { |
466 |
public boolean isEnum() { |
417 |
return javaClass.isEnum(); |
467 |
return isEnum;//javaClass.isEnum(); |
418 |
} |
468 |
} |
419 |
|
469 |
|
420 |
public boolean isAnnotation() { |
470 |
public boolean isAnnotation() { |
421 |
return javaClass.isAnnotation(); |
471 |
return isAnnotation;//javaClass.isAnnotation(); |
422 |
} |
472 |
} |
423 |
|
473 |
|
424 |
public boolean isAnonymous() { |
474 |
public boolean isAnonymous() { |
425 |
return javaClass.isAnonymous(); |
475 |
return isAnonymous;//javaClass.isAnonymous(); |
426 |
} |
476 |
} |
427 |
|
477 |
|
428 |
public boolean isNested() { |
478 |
public boolean isNested() { |
429 |
return javaClass.isNested(); |
479 |
return isNested;//javaClass.isNested(); |
430 |
} |
480 |
} |
431 |
|
481 |
|
432 |
public void addAnnotation(AnnotationX annotation) { |
482 |
public void addAnnotation(AnnotationX annotation) { |
Lines 552-558
Link Here
|
552 |
|
602 |
|
553 |
interfaces = newInterfaceNames; |
603 |
interfaces = newInterfaceNames; |
554 |
} |
604 |
} |
555 |
//System.err.println("javaClass: " + Arrays.asList(javaClass.getInterfaceNames()) + " super " + javaClass.getSuperclassName()); |
605 |
//System.err.println("javaClass: " + Arrays.asList(javaClass.getInterfaceNames()) + " super " + superclassName); |
556 |
//if (lazyClassGen != null) lazyClassGen.print(); |
606 |
//if (lazyClassGen != null) lazyClassGen.print(); |
557 |
} |
607 |
} |
558 |
|
608 |
|
Lines 609-615
Link Here
|
609 |
} |
659 |
} |
610 |
|
660 |
|
611 |
Signature.ClassSignature getGenericClassTypeSignature() { |
661 |
Signature.ClassSignature getGenericClassTypeSignature() { |
612 |
return javaClass.getGenericClassTypeSignature(); |
662 |
return cachedGenericClassTypeSignature; |
613 |
} |
663 |
} |
614 |
|
664 |
|
615 |
private boolean genericSignatureUnpacked = false; |
665 |
private boolean genericSignatureUnpacked = false; |
Lines 647-653
Link Here
|
647 |
} catch (GenericSignatureFormatException e) { |
697 |
} catch (GenericSignatureFormatException e) { |
648 |
// development bug, fail fast with good info |
698 |
// development bug, fail fast with good info |
649 |
throw new IllegalStateException( |
699 |
throw new IllegalStateException( |
650 |
"While determing the generic superclass of " + this.javaClass.getClassName() |
700 |
"While determing the generic superclass of " + this.className |
651 |
+ " with generic signature " + this.javaClass.getGenericSignature() + " the following error was detected: " |
701 |
+ " with generic signature " + this.javaClass.getGenericSignature() + " the following error was detected: " |
652 |
+ e.getMessage()); |
702 |
+ e.getMessage()); |
653 |
} |
703 |
} |
Lines 662-668
Link Here
|
662 |
} catch (GenericSignatureFormatException e) { |
712 |
} catch (GenericSignatureFormatException e) { |
663 |
// development bug, fail fast with good info |
713 |
// development bug, fail fast with good info |
664 |
throw new IllegalStateException( |
714 |
throw new IllegalStateException( |
665 |
"While determing the generic superinterfaces of " + this.javaClass.getClassName() |
715 |
"While determing the generic superinterfaces of " + this.className |
666 |
+ " with generic signature " + this.javaClass.getGenericSignature() + " the following error was detected: " |
716 |
+ " with generic signature " + this.javaClass.getGenericSignature() + " the following error was detected: " |
667 |
+ e.getMessage()); |
717 |
+ e.getMessage()); |
668 |
} |
718 |
} |
Lines 687-699
Link Here
|
687 |
} |
737 |
} |
688 |
|
738 |
|
689 |
private boolean isNestedClass() { |
739 |
private boolean isNestedClass() { |
690 |
return javaClass.getClassName().indexOf('$') != -1; |
740 |
return className.indexOf('$') != -1; |
691 |
} |
741 |
} |
692 |
|
742 |
|
693 |
private ReferenceType getOuterClass() { |
743 |
private ReferenceType getOuterClass() { |
694 |
if (!isNestedClass()) throw new IllegalStateException("Can't get the outer class of a non-nested type"); |
744 |
if (!isNestedClass()) throw new IllegalStateException("Can't get the outer class of a non-nested type"); |
695 |
int lastDollar = javaClass.getClassName().lastIndexOf('$'); |
745 |
int lastDollar = className.lastIndexOf('$'); |
696 |
String superClassName = javaClass.getClassName().substring(0,lastDollar); |
746 |
String superClassName = className.substring(0,lastDollar); |
697 |
UnresolvedType outer = UnresolvedType.forName(superClassName); |
747 |
UnresolvedType outer = UnresolvedType.forName(superClassName); |
698 |
return (ReferenceType) outer.resolve(getResolvedTypeX().getWorld()); |
748 |
return (ReferenceType) outer.resolve(getResolvedTypeX().getWorld()); |
699 |
} |
749 |
} |
Lines 732-738
Link Here
|
732 |
} |
782 |
} |
733 |
|
783 |
|
734 |
public String toString() { |
784 |
public String toString() { |
735 |
return (javaClass==null?"BcelObjectType":"BcelObjectTypeFor:"+javaClass.getClassName()); |
785 |
return (javaClass==null?"BcelObjectType":"BcelObjectTypeFor:"+className); |
736 |
} |
786 |
} |
737 |
|
787 |
|
738 |
// for testing - if we have this attribute, return it - will return null if it doesnt know anything |
788 |
// for testing - if we have this attribute, return it - will return null if it doesnt know anything |