private boolean fastDelegateSupportEnabled = isASMAround;
private boolean runMinimalMemory = false;
public boolean forDEBUG_structuralChangesCode = false;
+ public boolean forDEBUG_bridgingCode = false;
// Records whether ASM is around ... so we might use it for delegates
public final static String xsetACTIVATE_LIGHTWEIGHT_DELEGATES = "activateLightweightDelegates"; // default true
public final static String xsetRUN_MINIMAL_MEMORY ="runMinimalMemory"; // default true
public final static String xsetDEBUG_STRUCTURAL_CHANGES_CODE = "debugStructuralChangesCode"; // default false
+ public final static String xsetDEBUG_BRIDGING = "debugBridging"; // default false
public boolean isInJava5Mode() {
return behaveInJava5Way;
}
String s = p.getProperty(xsetRUN_MINIMAL_MEMORY,"false");
- runMinimalMemory = s.equalsIgnoreCase("true");
-// if (runMinimalMemory)
-// getMessageHandler().handleMessage(MessageUtil.info("[runMinimalMemory=true] Optimizing bcel processing (and cost of performance) to use less memory"));
+ runMinimalMemory = s.equalsIgnoreCase("true");
+// if (runMinimalMemory)
+// getMessageHandler().handleMessage(MessageUtil.info("[runMinimalMemory=true] Optimizing bcel processing (and cost of performance) to use less memory"));
+
+
+ s = p.getProperty(xsetDEBUG_STRUCTURAL_CHANGES_CODE,"false");
+ forDEBUG_structuralChangesCode = s.equalsIgnoreCase("true");
+
+ s = p.getProperty(xsetDEBUG_BRIDGING,"false");
+ forDEBUG_bridgingCode = s.equalsIgnoreCase("true");
-
- s = p.getProperty(xsetDEBUG_STRUCTURAL_CHANGES_CODE,"false");
- forDEBUG_structuralChangesCode = s.equalsIgnoreCase("true");
-
- }
- checkedAdvancedConfiguration=true;
+ }
+ checkedAdvancedConfiguration=true;
}
}
Type paramType = paramTypes[i];
body.append(InstructionFactory.createLoad(paramType, pos));
if (!newParamTypes[i].equals(paramTypes[i])) {
- if (debug) System.err.println("Cast "+newParamTypes[i]+" from "+paramTypes[i]);
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging: Cast "+newParamTypes[i]+" from "+paramTypes[i]);
body.append(fact.createCast(paramTypes[i],newParamTypes[i]));
}
pos+=paramType.getSize();
// **************************** start of bridge method creation code *****************
- // debug flag for bridge method creation
- public static boolean debug=false;
-
-
// FIXME asc tidy this lot up !!
// FIXME asc refactor into ResolvedType or even ResolvedMember?
if (methodThatMightBeGettingOverridden.getParameterTypes().length!=methodParamsArray.length) return null; // check same number of parameters
if (!isVisibilityOverride(mmods,methodThatMightBeGettingOverridden,inSamePackage)) return null;
- if (debug) System.err.println(" Seriously considering this might be getting overridden "+methodThatMightBeGettingOverridden);
+ if (typeToCheck.getWorld().forDEBUG_bridgingCode) System.err.println(" Bridging:seriously considering this might be getting overridden '"+methodThatMightBeGettingOverridden+"'");
// Look at erasures of parameters (List<String> erased is List)
boolean sameParams = true;
if (typeToCheck.isParameterizedType()) {
return methodThatMightBeGettingOverridden.getBackingGenericMember();
} else if (!methodThatMightBeGettingOverridden.getReturnType().getErasureSignature().equals(mrettype)) {
- return methodThatMightBeGettingOverridden; // covariance
+ // addressing the wierd situation from bug 147801
+ // just check whether these things are in the right relationship for covariance...
+ ResolvedType superReturn = typeToCheck.getWorld().resolve(UnresolvedType.forSignature(methodThatMightBeGettingOverridden.getReturnType().getErasureSignature()));
+ ResolvedType subReturn = typeToCheck.getWorld().resolve(UnresolvedType.forSignature(mrettype));
+ if (superReturn.isAssignableFrom(subReturn))
+ return methodThatMightBeGettingOverridden;
}
}
return null;
if (typeToCheck==null) return null;
if (typeToCheck instanceof MissingResolvedTypeWithKnownSignature) return null; // we just can't tell !
- if (debug) System.err.println(" Checking for override of "+mname+" in "+typeToCheck);
+ if (typeToCheck.getWorld().forDEBUG_bridgingCode) System.err.println(" Bridging:checking for override of "+mname+" in "+typeToCheck);
String packageName = typeToCheck.getPackageName();
if (packageName==null) packageName="";
if (o instanceof BcelTypeMunger) {
BcelTypeMunger element = (BcelTypeMunger)o;
if (element.getMunger() instanceof NewMethodTypeMunger) {
- if (debug) System.err.println("Possible ITD candidate "+element);
+ if (typeToCheck.getWorld().forDEBUG_bridgingCode) System.err.println("Possible ITD candidate "+element);
ResolvedMember aMethod = element.getSignature();
ResolvedMember isOverriding = isOverriding(typeToCheck,aMethod,mname,mrettype,mmods,inSamePackage,methodParamsArray);
if (isOverriding!=null) return isOverriding;
* See pr108101
*/
public static boolean calculateAnyRequiredBridgeMethods(BcelWorld world,LazyClassGen clazz) {
+ world.ensureAdvancedConfigurationProcessed();
if (!world.isInJava5Mode()) return false; // just double check... the caller should have already verified this
if (clazz.isInterface()) return false; // dont bother if we're an interface
boolean didSomething=false; // set if we build any bridge methods
if (bridgeToCandidate.isStatic()) continue; // ignore static methods
if (name.endsWith("init>")) continue; // Skip constructors and static initializers
- if (debug) System.err.println("Determining if we have to bridge to "+clazz.getName()+"."+name+""+bridgeToCandidate.getSignature());
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging: Determining if we have to bridge to "+clazz.getName()+"."+name+""+bridgeToCandidate.getSignature());
// Let's take a look at the superclass
ResolvedType theSuperclass= clazz.getSuperClass();
- if (debug) System.err.println("Checking supertype "+theSuperclass);
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging: Checking supertype "+theSuperclass);
String pkgName = clazz.getPackageName();
UnresolvedType[] bm = BcelWorld.fromBcel(bridgeToCandidate.getArgumentTypes());
ResolvedMember overriddenMethod = checkForOverride(theSuperclass,name,psig,rsig,bridgeToCandidate.getAccessFlags(),pkgName,bm);
if (overriddenMethod!=null) {
boolean alreadyHaveABridgeMethod = methodsSet.contains(overriddenMethod.getName()+overriddenMethod.getSignature());
if (!alreadyHaveABridgeMethod) {
- if (debug) System.err.println("Bridging to "+overriddenMethod);
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging:bridging to '"+overriddenMethod+"'");
createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
didSomething = true;
continue; // look at the next method
// Check superinterfaces
String[] interfaces = clazz.getInterfaceNames();
for (int j = 0; j < interfaces.length; j++) {
- if (debug) System.err.println("Checking superinterface "+interfaces[j]);
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging:checking superinterface "+interfaces[j]);
ResolvedType interfaceType = world.resolve(interfaces[j]);
overriddenMethod = checkForOverride(interfaceType,name,psig,rsig,bridgeToCandidate.getAccessFlags(),clazz.getPackageName(),bm);
if (overriddenMethod!=null) {
if (!alreadyHaveABridgeMethod) {
createBridgeMethod(world, bridgeToCandidate, clazz, overriddenMethod);
didSomething=true;
- if (debug) System.err.println("Bridging to "+overriddenMethod);
+ if (world.forDEBUG_bridgingCode) System.err.println("Bridging:bridging to "+overriddenMethod);
continue; // look at the next method
}
}