/** * Lookup a type by its signature, always look in the real map before the expendable map */ public ResolvedType get(String key) { checkq(); ResolvedType ret = tMap.get(key); if (ret == null) { if (policy == USE_WEAK_REFS) { WeakReference<ResolvedType> ref = (WeakReference<ResolvedType>) expendableMap.get(key); if (ref != null) { ret = ref.get(); // if (ret==null) { // expendableMap.remove(key); // } } } else if (policy == USE_SOFT_REFS) { SoftReference<ResolvedType> ref = (SoftReference<ResolvedType>) expendableMap.get(key); if (ref != null) { ret = ref.get(); // if (ret==null) { // expendableMap.remove(key); // } } // } else { // return (ResolvedType) expendableMap.get(key); } } return ret; }
@Override public void classWriteEvent(char[][] compoundName) { typeMap.classWriteEvent(new String(CharOperation.concatWith(compoundName, '.'))); }
public BcelObjectType addSourceObjectType(String classname, byte[] bytes, boolean artificial) { BcelObjectType retval = null; String signature = UnresolvedType.forName(classname).getSignature(); ResolvedType resolvedTypeFromTypeMap = typeMap.get(signature); genericRefType.setDelegate(retval); referenceTypeFromTypeMap.setGenericType(genericRefType); typeMap.put(signature, referenceTypeFromTypeMap); } else { referenceTypeFromTypeMap = new ReferenceType(signature, this); retval = buildBcelDelegate(referenceTypeFromTypeMap, jc, artificial, true); typeMap.put(signature, referenceTypeFromTypeMap);
if (typeMungers == null || typeMungers.size() == 0) { tMap.remove(key); insertInExpendableMap(key, type); demotionCounter++; insertInExpendableMap(key, type); demotionCounter++;
ResolvedType ret = typeMap.get(signature); if (ret != null) { ret.world = this; // Set the world for the RTX typeMap.put("?", something); return something; ResolvedType result = typeMap.get(signature); if (result == null && !ret.isMissing()) { ret = ensureRawTypeIfNecessary(ret); typeMap.put(signature, ret); return ret;
ResolvedType resolvedTypeFromTypeMap = typeMap.get(signature); genericRefType.setDelegate(ret); rawType.setGenericType(genericRefType); typeMap.put(signature, rawType); } else { referenceTypeFromTypeMap = new ReferenceType(signature, this); ret = buildBcelDelegate(referenceTypeFromTypeMap, jc, artificial, true); typeMap.put(signature, referenceTypeFromTypeMap);
/** * The aim of this method is to make sure a particular type is 'ok'. Some operations on the delegate for a type modify it and * this method is intended to undo that... see pr85132 */ @Override public void validateType(UnresolvedType type) { ResolvedType result = typeMap.get(type.getSignature()); if (result == null) { return; // We haven't heard of it yet } if (!result.isExposedToWeaver()) { return; // cant need resetting } result.ensureConsistent(); // If we want to rebuild it 'from scratch' then: // ClassParser cp = new ClassParser(new // ByteArrayInputStream(newbytes),new String(cs)); // try { // rt.setDelegate(makeBcelObjectType(rt,cp.parse(),true)); // } catch (ClassFormatException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } }
/** * Some TypeFactory operations create resolved types directly, but these won't be in the typeMap - this resolution process puts * them there. Resolved types are also told their world which is needed for the special autoboxing resolved types. */ public ResolvedType resolve(ResolvedType ty) { if (ty.isTypeVariableReference()) { return ty; // until type variables have proper sigs... } ResolvedType resolved = typeMap.get(ty.getSignature()); if (resolved == null) { resolved = ensureRawTypeIfNecessary(ty); typeMap.put(ty.getSignature(), resolved); resolved = ty; } resolved.world = this; return resolved; }
public int demote() { return demote(false); }
void deleteSourceObjectType(UnresolvedType ty) { typeMap.remove(ty.getSignature()); }
/** * Insert the primitives */ protected World() { super(); // Dump.registerNode(this.getClass(), this); typeMap.put("B", BYTE); typeMap.put("S", SHORT); typeMap.put("I", INT); typeMap.put("J", LONG); typeMap.put("F", FLOAT); typeMap.put("D", DOUBLE); typeMap.put("C", CHAR); typeMap.put("Z", BOOLEAN); typeMap.put("V", VOID); precedenceCalculator = new AspectPrecedenceCalculator(this); }
/** * Ask the type map to demote any types it can - we don't want them anchored forever. */ public void demote() { typeMap.demote(); }
/** * Force demote a type. */ public void demote(ResolvedType type) { typeMap.demote(type); }
public void demote(ResolvedType type) { String key = type.getSignature(); if (debugDemotion) { addedSinceLastDemote.remove(key); } tMap.remove(key); insertInExpendableMap(key, type); }
/** * Lookup a reference type in the world by its signature. Returns null if not found. */ public ReferenceType lookupBySignature(String signature) { return (ReferenceType) typeMap.get(signature); }
public void report() { if (!memoryProfiling) { return; } checkq(); w.getMessageHandler().handleMessage( MessageUtil.info("MEMORY: world expendable type map reached maximum size of #" + maxExpendableMapSize + " entries")); w.getMessageHandler().handleMessage( MessageUtil.info("MEMORY: types collected through garbage collection #" + collectedTypes + " entries")); }
/** * Lookup a type by signature, if not found then build one and put it in the map. */ public ReferenceType lookupOrCreateName(UnresolvedType ty) { String signature = ty.getSignature(); ReferenceType ret = lookupBySignature(signature); if (ret == null) { ret = ReferenceType.fromTypeX(ty, this); typeMap.put(signature, ret); } return ret; }