@@ -34,6 +34,9 @@ public class Lint { | |||
public final Kind unresolvableMember = | |||
new Kind("unresolvableMember", "can not resolve this member: {0}"); | |||
public final Kind typeNotExposedToWeaver = | |||
new Kind("typeNotExposedToWeaver", "this affected type is not exposed to the weaver: {0}"); | |||
public Lint(World world) { | |||
this.world = world; |
@@ -46,7 +46,14 @@ public abstract class ResolvedTypeMunger { | |||
public boolean matches(ResolvedTypeX matchType) { | |||
ResolvedTypeX onType = matchType.getWorld().resolve(signature.getDeclaringType()); | |||
//System.err.println("matching: " + this + " to " + matchType + " onType = " + onType); | |||
if (matchType.equals(onType)) return true; | |||
if (matchType.equals(onType)) { | |||
if (!onType.isExposedToWeaver() && | |||
matchType.getWorld().getLint().typeNotExposedToWeaver.isEnabled()) | |||
{ | |||
matchType.getWorld().getLint().typeNotExposedToWeaver.signal(matchType.getName(), signature.getSourceLocation()); | |||
} | |||
return true; | |||
} | |||
//System.err.println("NO MATCH DIRECT"); | |||
if (onType.isInterface()) { |
@@ -25,6 +25,7 @@ import org.aspectj.weaver.patterns.PerClause; | |||
public abstract class ResolvedTypeX extends TypeX { | |||
protected World world; | |||
ResolvedTypeX(String signature, World world) { | |||
super(signature); | |||
@@ -508,9 +509,12 @@ public abstract class ResolvedTypeX extends TypeX { | |||
public static abstract class Name extends ResolvedTypeX { | |||
protected ISourceContext sourceContext; | |||
protected boolean exposedToWeaver; | |||
public Name(String signature, World world) { | |||
public Name(String signature, World world, boolean exposedToWeaver) { | |||
super(signature, world); | |||
this.exposedToWeaver = exposedToWeaver; | |||
} | |||
public final boolean isClass() { | |||
@@ -565,6 +569,10 @@ public abstract class ResolvedTypeX extends TypeX { | |||
return sourceContext; | |||
} | |||
public boolean isExposedToWeaver() { | |||
return exposedToWeaver; | |||
} | |||
} | |||
static class Array extends ResolvedTypeX { | |||
@@ -1097,4 +1105,5 @@ public abstract class ResolvedTypeX extends TypeX { | |||
} | |||
public ISourceLocation getSourceLocation() { return null; } | |||
public boolean isExposedToWeaver() { return false; } | |||
} |
@@ -1,4 +1,6 @@ | |||
invalidAbsoluteTypeName = warning | |||
invalidWildcardTypeName = ignore | |||
unresolvableMember = warning | |||
unresolvableMember = warning | |||
typeNotExposedToWeaver = warning |
@@ -58,8 +58,8 @@ public class BcelObjectType extends ResolvedTypeX.Name { | |||
// IMPORTANT! THIS DOESN'T do real work on the java class, just stores it away. | |||
BcelObjectType(String signature, World world, JavaClass javaClass) { | |||
super(signature, world); | |||
BcelObjectType(String signature, World world, JavaClass javaClass, boolean exposedToWeaver) { | |||
super(signature, world, exposedToWeaver); | |||
this.javaClass = javaClass; | |||
sourceContext = new BcelSourceContext(this); | |||
@@ -146,6 +146,7 @@ public class BcelObjectType extends ResolvedTypeX.Name { | |||
List l = BcelAttributes.readAjAttributes(javaClass.getAttributes(), getSourceContext()); | |||
for (Iterator iter = l.iterator(); iter.hasNext();) { | |||
AjAttribute a = (AjAttribute) iter.next(); | |||
//System.err.println("unpacking: " + this + " and " + a); | |||
if (a instanceof AjAttribute.Aspect) { | |||
perClause = ((AjAttribute.Aspect)a).reify(this); | |||
} else if (a instanceof AjAttribute.PointcutDeclarationAttribute) { | |||
@@ -181,13 +182,7 @@ public class BcelObjectType extends ResolvedTypeX.Name { | |||
return javaClass; | |||
} | |||
/** | |||
* Switch to a new JavaClass and clear all caches | |||
*/ | |||
void replaceJavaClass(JavaClass jc) { | |||
if (this.javaClass == jc) return; | |||
this.javaClass = jc; | |||
void resetState() { | |||
this.interfaces = null; | |||
this.superClass = null; | |||
this.fields = null; | |||
@@ -199,7 +194,17 @@ public class BcelObjectType extends ResolvedTypeX.Name { | |||
isObject = (javaClass.getSuperclassNameIndex() == 0); | |||
unpackAspectAttributes(); | |||
//XXX is clearing these caches sufficient | |||
} | |||
/** | |||
* Switch to a new JavaClass and clear all caches | |||
*/ | |||
void replaceJavaClass(JavaClass jc) { | |||
if (this.javaClass == jc) return; | |||
this.javaClass = jc; | |||
resetState(); | |||
} | |||
public WeaverStateKind getWeaverState() { | |||
@@ -227,6 +232,7 @@ public class BcelObjectType extends ResolvedTypeX.Name { | |||
public LazyClassGen getLazyClassGen() { | |||
LazyClassGen ret = lazyClassGen; | |||
if (ret == null) { | |||
//System.err.println("creating lazy class gen for: " + this); | |||
ret = new LazyClassGen(this); | |||
if (isAspect()) { | |||
lazyClassGen = ret; |
@@ -224,6 +224,18 @@ public class BcelWeaver implements IWeaver { | |||
"(world=" + needToReweaveWorld + ")", null, null); | |||
//System.err.println("typeMungers: " + typeMungerList); | |||
// clear all state from files we'll be reweaving | |||
for (Iterator i = filesToWeave.iterator(); i.hasNext(); ) { | |||
UnwovenClassFile classFile = (UnwovenClassFile)i.next(); | |||
String className = classFile.getClassName(); | |||
BcelObjectType classType = (BcelObjectType) world.resolve(className); | |||
classType.resetState(); | |||
} | |||
//XXX this isn't quite the right place for this... | |||
for (Iterator i = filesToWeave.iterator(); i.hasNext(); ) { | |||
UnwovenClassFile classFile = (UnwovenClassFile)i.next(); | |||
@@ -290,6 +302,7 @@ public class BcelWeaver implements IWeaver { | |||
if (shadowMungers.size() > 0 || typeMungers.size() > 0 || classType.isAspect()) { | |||
clazz = classType.getLazyClassGen(); | |||
//System.err.println("got lazy gen: " + clazz + ", " + clazz.getWeaverState()); | |||
try { | |||
boolean isChanged = BcelClassWeaver.weave(world, clazz, shadowMungers, typeMungers); | |||
if (isChanged) { |
@@ -170,7 +170,7 @@ public class BcelWorld extends World { | |||
if (jc == null) { | |||
return ResolvedTypeX.MISSING; | |||
} else { | |||
return new BcelObjectType(ty.getSignature(), this, jc); | |||
return new BcelObjectType(ty.getSignature(), this, jc, false); | |||
} | |||
} | |||
@@ -195,7 +195,7 @@ public class BcelWorld extends World { | |||
String signature = TypeX.forName(jc.getClassName()).getSignature(); | |||
BcelObjectType ret = (BcelObjectType)typeMap.get(signature); | |||
if (ret == null) { | |||
ret = new BcelObjectType(signature, this, jc); | |||
ret = new BcelObjectType(signature, this, jc, true); | |||
typeMap.put(signature, ret); | |||
} else { | |||
ret.replaceJavaClass(jc); |
@@ -1,45 +0,0 @@ | |||
/* ******************************************************************* | |||
* 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 Common Public License v1.0 | |||
* which accompanies this distribution and is available at | |||
* http://www.eclipse.org/legal/cpl-v10.html | |||
* | |||
* Contributors: | |||
* Xerox/PARC initial implementation | |||
* ******************************************************************/ | |||
package org.aspectj.weaver.bcel; | |||
import java.io.IOException; | |||
import java.util.List; | |||
import java.util.zip.*; | |||
//XXX we believe this is now unneeded | |||
public class UnwovenZipClassFile extends UnwovenClassFile { | |||
private ZipOutputStream zipOutputStream; | |||
public UnwovenZipClassFile(ZipOutputStream zipOutputStream, String filename, byte[] bytes) { | |||
super(filename, bytes); | |||
this.zipOutputStream = zipOutputStream; | |||
} | |||
public void writeWovenBytes(byte[] bytes, List childClasses) throws IOException { | |||
//??? we rewrite this every time | |||
if (!childClasses.isEmpty()) { | |||
throw new RuntimeException("unimplemented"); | |||
} | |||
ZipEntry newEntry = new ZipEntry(filename); //??? get compression scheme right | |||
zipOutputStream.putNextEntry(newEntry); | |||
zipOutputStream.write(bytes); | |||
zipOutputStream.closeEntry(); | |||
writtenBytes = bytes; | |||
} | |||
} |
@@ -34,10 +34,15 @@ public class DeclareParents extends Declare { | |||
} | |||
public boolean match(ResolvedTypeX typeX) { | |||
return child.matchesStatically(typeX); | |||
if (!child.matchesStatically(typeX)) return false; | |||
if (typeX.getWorld().getLint().typeNotExposedToWeaver.isEnabled() && | |||
!typeX.isExposedToWeaver()) | |||
{ | |||
typeX.getWorld().getLint().typeNotExposedToWeaver.signal(typeX.getName(), getSourceLocation()); | |||
} | |||
return true; | |||
} | |||
public String toString() { | |||
StringBuffer buf = new StringBuffer(); |