public String getSourcefilename() { // crappy guess.. return resolvedType.getName() + ".class"; }
public static ReflectionBasedReferenceTypeDelegate create14Delegate(ReferenceType forReferenceType, World inWorld, ClassLoader usingClassLoader) { try { Class c = Class.forName(forReferenceType.getName(), false, usingClassLoader); return new ReflectionBasedReferenceTypeDelegate(c, usingClassLoader, inWorld, forReferenceType); } catch (ClassNotFoundException cnfEx) { return null; } }
public void setGenericType(ReferenceType rt) { genericType = rt; // Should we 'promote' this reference type from simple to raw? // makes sense if someone is specifying that it has a generic form if (typeKind == TypeKind.SIMPLE) { typeKind = TypeKind.RAW; signatureErasure = signature; if (newInterfaces != null) { // debug 375777 throw new IllegalStateException( "Simple type promoted to raw, but simple type had new interfaces/superclass. Type is " + this.getName()); } } if (typeKind == TypeKind.RAW) { genericType.addDependentType(this); } if (isRawType()) { genericType.rawType = this; } if (this.isRawType() && rt.isRawType()) { new RuntimeException( "PR341926 diagnostics: Incorrect setup for a generic type, raw type should not point to raw: " + this.getName()).printStackTrace(); } }
public final void setSourcefilename(String sourceFileName) { sourcefilename = sourceFileName; if (sourceFileName != null && sourceFileName.equals(AbstractReferenceTypeDelegate.UNKNOWN_SOURCE_FILE)) { sourcefilename = "Type '" + getResolvedTypeX().getName() + "' (no debug info available)"; } else { String pname = getResolvedTypeX().getPackageName(); if (pname != null) { sourcefilename = pname.replace('.', '/') + '/' + sourceFileName; } } if (sourcefilename != null && sourceContext instanceof SourceContextImpl) { ((SourceContextImpl) sourceContext).setSourceFileName(sourcefilename); } }
public static ReflectionBasedReferenceTypeDelegate createDelegate(ReferenceType forReferenceType, World inWorld, ClassLoader usingClassLoader) { try { Class c = Class.forName(forReferenceType.getName(), false, usingClassLoader); if (LangUtil.is15VMOrGreater()) { ReflectionBasedReferenceTypeDelegate rbrtd = create15Delegate(forReferenceType, c, usingClassLoader, inWorld); if (rbrtd != null) { return rbrtd; // can be null if we didn't find the class the delegate logic loads } } return new ReflectionBasedReferenceTypeDelegate(c, usingClassLoader, inWorld, forReferenceType); } catch (ClassNotFoundException cnfEx) { return null; } }
public void warnOnModifiedSerialVersionUID(ISourceLocation sourceLocation, String reason) { if (isSerializable && !hasSerialVersionUIDField) { getWorld().getLint().needsSerialVersionUIDField.signal(new String[] { myType.getResolvedTypeX().getName().toString(), reason }, sourceLocation, null); } }
public WeavingClassFileProvider(String name, byte[] bytes) { ensureDelegateInitialized(name, bytes); this.unwovenClass = new UnwovenClassFile(name, delegateForCurrentClass.getResolvedTypeX().getName(), bytes); this.unwovenClasses.add(unwovenClass); if (shouldDump(name.replace('/', '.'), true)) { dump(name, bytes, true); } }
throw new IllegalStateException( "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is " + this.getName());
@Override public ResolvedType[] getAnnotationTypes() { if (getDelegate() == null) { throw new BCException("Unexpected null delegate for type " + this.getName()); } if (annotationTypes == null) { // there are no extras: return getDelegate().getAnnotationTypes(); } else { ResolvedType[] delegateAnnotationTypes = getDelegate() .getAnnotationTypes(); ResolvedType[] result = new ResolvedType[annotationTypes.length + delegateAnnotationTypes.length]; System.arraycopy(delegateAnnotationTypes, 0, result, 0, delegateAnnotationTypes.length); System.arraycopy(annotationTypes, 0, result, delegateAnnotationTypes.length, annotationTypes.length); return result; } }
public void errorOnAddedField(FieldGen field, ISourceLocation sourceLocation) { if (isSerializable && !hasSerialVersionUIDField) { getWorld().getLint().serialVersionUIDBroken.signal( new String[] { myType.getResolvedTypeX().getName(), field.getName() }, sourceLocation, null); } }
if (simpleName != null) { if (typeVariableMap.containsKey(simpleName)) { String newName = ((ReferenceType) typeVariableMap.get(simpleName)).getName().replace('$', '.'); StringTokenizer strTok = new StringTokenizer(newName, "."); newNamePatterns = new NamePattern[strTok.countTokens()];
@Override protected ReferenceTypeDelegate resolveDelegate(ReferenceType ty) { String name = ty.getName(); ensureAdvancedConfigurationProcessed(); JavaClass jc = lookupJavaClass(classPath, name); if (jc == null) { // Anyone else to ask? if (typeDelegateResolvers != null) { for (TypeDelegateResolver tdr : typeDelegateResolvers) { ReferenceTypeDelegate delegate = tdr.getDelegate(ty); if (delegate != null) { return delegate; } } } return null; } else { return buildBcelDelegate(ty, jc, false, false); } }
public boolean hasAnnotation(UnresolvedType ofType) { // Due to re-entrancy we may be in the middle of unpacking the annotations already... in which case use this slow // alternative until the stack unwinds itself if (isUnpackingAnnotations()) { AnnotationGen annos[] = javaClass.getAnnotations(); if (annos == null || annos.length == 0) { return false; } else { String lookingForSignature = ofType.getSignature(); for (int a = 0; a < annos.length; a++) { AnnotationGen annotation = annos[a]; if (lookingForSignature.equals(annotation.getTypeSignature())) { return true; } } } return false; } ensureAnnotationsUnpacked(); for (int i = 0, max = annotationTypes.length; i < max; i++) { UnresolvedType ax = annotationTypes[i]; if (ax == null) { throw new RuntimeException("Annotation entry " + i + " on type " + this.getResolvedTypeX().getName() + " is null!"); } if (ax.equals(ofType)) { return true; } } return false; }
throw new IllegalStateException( "The raw type should never be accumulating new interfaces, they should be on the generic type. Type is " + this.getName());
ResolvedType rType = w.resolve(UnresolvedType.forSignature(typeSignature)); if (rType == null) { throw new RuntimeException("Whilst unpacking annotations on '" + getResolvedTypeX().getName() + "', failed to resolve type '" + typeSignature + "'");
msgHandler.handleMessage(MessageUtil.error("The generic aspect '" + getResolvedTypeX().getName() + "' must be declared abstract", getResolvedTypeX().getSourceLocation()));
private void weaveAndNotify(UnwovenClassFile classFile, BcelObjectType classType, IWeaveRequestor requestor) throws IOException { trace.enter("weaveAndNotify", this, new Object[] { classFile, classType, requestor }); ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_TYPE, classType .getResolvedTypeX().getName()); LazyClassGen clazz = weaveWithoutDump(classFile, classType); classType.finishedWith(); // clazz is null if the classfile was unchanged by weaving... if (clazz != null) { UnwovenClassFile[] newClasses = getClassFilesFor(clazz); // OPTIMIZE can we avoid using the string name at all in // UnwovenClassFile instances? // Copy the char[] across as it means the // WeaverAdapter.removeFromMap() can be fast! if (newClasses[0].getClassName().equals(classFile.getClassName())) { newClasses[0].setClassNameAsChars(classFile.getClassNameAsChars()); } for (int i = 0; i < newClasses.length; i++) { requestor.acceptResult(newClasses[i]); } } else { requestor.acceptResult(classFile); } classType.weavingCompleted(); CompilationAndWeavingContext.leavingPhase(tok); trace.exit("weaveAndNotify"); }
if (pnames == null || (pnames.length != ptypes.length)) { throw new IllegalStateException("Required parameter names not available when parsing pointcut " + pcs[i].getName() + " in type " + getResolvedTypeX().getName());
throw new IllegalStateException( "Simple type promoted forced to raw, but it had new interfaces/superclass. Type is " + simpleOrRawType.getName());