From ffda2dde2ddcafc429cc36f19433cdc39401ea1e Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Fri, 14 Jan 2022 22:34:54 +0300 Subject: [PATCH] Update 'weaver' code to use generics --- .../main/java/org/aspectj/weaver/bcel/BcelWeaver.java | 8 ++++---- .../aspectj/weaver/bcel/ExtensibleURLClassLoader.java | 2 +- .../weaver/loadtime/definition/LightXMLParser.java | 6 +++--- .../weaver/loadtime/definition/SimpleAOPParser.java | 6 +++--- .../src/main/java/org/aspectj/weaver/ltw/LTWWorld.java | 8 ++++---- .../aspectj/weaver/reflect/Java15AnnotationFinder.java | 10 +++++----- .../Java15GenericSignatureInformationProvider.java | 6 +++--- .../Java15ReflectionBasedReferenceTypeDelegate.java | 4 ++-- .../reflect/JavaLangTypeToResolvedTypeConverter.java | 4 ++-- .../java/org/aspectj/weaver/tools/WeavingAdaptor.java | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java index 51f0a8c6c..53f71df56 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java @@ -386,7 +386,7 @@ public class BcelWeaver { inJar = new JarFile(inFile); try { addManifest(inJar.getManifest()); - Enumeration entries = inJar.entries(); + Enumeration entries = inJar.entries(); while (entries.hasMoreElements()) { JarEntry entry = (JarEntry) entries.nextElement(); @@ -878,7 +878,7 @@ public class BcelWeaver { return true; } - private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) { + private Pointcut findFirstPointcutIn(Pointcut toSearch, Class toLookFor) { if (toSearch instanceof NotPointcut) { return null; } @@ -946,7 +946,7 @@ public class BcelWeaver { manifest = new Manifest(); - Map attributes = manifest.getMainAttributes(); + Attributes attributes = manifest.getMainAttributes(); attributes.put(Name.MANIFEST_VERSION, WEAVER_MANIFEST_VERSION); attributes.put(CREATED_BY, WEAVER_CREATED_BY); } @@ -1254,7 +1254,7 @@ public class BcelWeaver { // if a piece of advice hasn't matched anywhere and we are in -1.5 mode, // put out a warning if (world.isInJava5Mode() && world.getLint().adviceDidNotMatch.isEnabled()) { - List l = world.getCrosscuttingMembersSet().getShadowMungers(); + List l = world.getCrosscuttingMembersSet().getShadowMungers(); Set alreadyWarnedLocations = new HashSet<>(); for (Object o : l) { diff --git a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java index 54aefa4b8..dd372e5e2 100644 --- a/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java +++ b/weaver/src/main/java/org/aspectj/weaver/bcel/ExtensibleURLClassLoader.java @@ -87,7 +87,7 @@ public abstract class ExtensibleURLClassLoader extends URLClassLoader { return b; } - private Class defineClass(String name, byte[] bytes /* ClassPathManager.ClassFile classFile */) throws IOException { + private Class defineClass(String name, byte[] bytes /* ClassPathManager.ClassFile classFile */) throws IOException { String packageName = getPackageName(name); if (packageName != null) { Package pakkage = getPackage(packageName); diff --git a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/LightXMLParser.java b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/LightXMLParser.java index 3d3fba430..c076c3a2f 100644 --- a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/LightXMLParser.java +++ b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/LightXMLParser.java @@ -20,7 +20,7 @@ public class LightXMLParser { private final static char NULL_CHAR = '\0'; private Map attributes; - private ArrayList children; + private ArrayList children; private String name; private char pushedBackChar; private Reader reader; @@ -38,7 +38,7 @@ public class LightXMLParser { public LightXMLParser() { this.name = null; this.attributes = new HashMap<>(); - this.children = new ArrayList(); + this.children = new ArrayList<>(); } public ArrayList getChildrens() { @@ -53,7 +53,7 @@ public class LightXMLParser { this.pushedBackChar = NULL_CHAR; this.attributes = new HashMap<>(); this.name = null; - this.children = new ArrayList(); + this.children = new ArrayList<>(); this.reader = reader; while (true) { diff --git a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java index c73b51af1..223d2c432 100644 --- a/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java +++ b/weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java @@ -80,7 +80,7 @@ public class SimpleAOPParser { return sap.m_definition; } - private void startElement(String qName, Map attrMap) throws Exception { + private void startElement(String qName, Map attrMap) throws Exception { if (ASPECT_ELEMENT.equals(qName)) { String name = (String) attrMap.get(NAME_ATTRIBUTE); String scopePattern = replaceXmlAnd((String) attrMap @@ -233,7 +233,7 @@ public class SimpleAOPParser { } } - private String getWithinAttribute(Map attributes) { + private String getWithinAttribute(Map attributes) { return replaceXmlAnd((String) attributes.get(WITHIN_ATTRIBUTE)); } @@ -253,7 +253,7 @@ public class SimpleAOPParser { private static void traverse(SimpleAOPParser sap, LightXMLParser xml) throws Exception { sap.startElement(xml.getName(), xml.getAttributes()); - Iterable childrens = xml.getChildrens(); + Iterable childrens = xml.getChildrens(); for (Object children : childrens) { LightXMLParser child = (LightXMLParser) children; traverse(sap, child); diff --git a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java index 7dc8b7dd4..4677a3939 100644 --- a/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java +++ b/weaver/src/main/java/org/aspectj/weaver/ltw/LTWWorld.java @@ -177,17 +177,17 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { return ReflectionWorld.resolve(this, aClass); } - private static Map makeConcurrentMap() { + private static Map makeConcurrentMap() { if (concurrentMapClass != null) { try { return (Map) concurrentMapClass.getDeclaredConstructor().newInstance(); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ignored) {} // fall through if exceptions } - return Collections.synchronizedMap(new HashMap()); + return Collections.synchronizedMap(new HashMap<>()); } - private static Class makeConcurrentMapClass() { + private static Class makeConcurrentMapClass() { String betterChoices[] = { "java.util.concurrent.ConcurrentHashMap", "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap", "EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap" }; @@ -215,7 +215,7 @@ public class LTWWorld extends BcelWorld implements IReflectionWorld { // One type is completed at a time, if multiple need doing then they // are queued up private boolean typeCompletionInProgress = false; - private List/* ResolvedType */typesForCompletion = new ArrayList(); + private List typesForCompletion = new ArrayList<>(); @Override protected void completeBinaryType(ResolvedType ret) { diff --git a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java index dfddd18da..d60857950 100644 --- a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java +++ b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15AnnotationFinder.java @@ -138,7 +138,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { anns = bcelMethod.getAnnotations(); } } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); + org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); anns = bcelCons.getAnnotations(); } else if (onMember instanceof Field) { org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember); @@ -208,7 +208,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { anns = bcelMethod.getAnnotations(); } } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); + org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); anns = bcelCons.getAnnotations(); } else if (onMember instanceof Field) { org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember); @@ -284,7 +284,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { lvt = bcelMethod.getLocalVariableTable(); numVars = bcelMethod.getArgumentTypes().length; } else if (forMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) forMember); + org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) forMember); lvt = bcelCons.getLocalVariableTable(); numVars = bcelCons.getArgumentTypes().length; } @@ -334,7 +334,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { anns = bcelMethod.getParameterAnnotations(); } } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); + org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); anns = bcelCons.getParameterAnnotations(); } else if (onMember instanceof Field) { // anns = null; @@ -364,7 +364,7 @@ public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { if (onMember instanceof Method) { anns = ((Method) ao).getParameterAnnotations(); } else if (onMember instanceof Constructor) { - anns = ((Constructor) ao).getParameterAnnotations(); + anns = ((Constructor) ao).getParameterAnnotations(); } else if (onMember instanceof Field) { // anns = null; } diff --git a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java index 3d298023e..69030fbd4 100644 --- a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java +++ b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java @@ -43,7 +43,7 @@ public class Java15GenericSignatureInformationProvider implements if (member instanceof Method) { pTypes = ((Method)member).getGenericParameterTypes(); } else if (member instanceof Constructor) { - pTypes = ((Constructor)member).getGenericParameterTypes(); + pTypes = ((Constructor)member).getGenericParameterTypes(); } return typeConverter.fromTypes(pTypes); } @@ -60,7 +60,7 @@ public class Java15GenericSignatureInformationProvider implements } else if (member instanceof Method) { return typeConverter.fromType(((Method)member).getGenericReturnType()); } else if (member instanceof Constructor) { - return typeConverter.fromType(((Constructor)member).getDeclaringClass()); + return typeConverter.fromType(((Constructor)member).getDeclaringClass()); } else { throw new IllegalStateException("unexpected member type: " + member); } @@ -86,7 +86,7 @@ public class Java15GenericSignatureInformationProvider implements if (member instanceof Method) { return ((Method)member).isVarArgs(); } else if (member instanceof Constructor) { - return ((Constructor)member).isVarArgs(); + return ((Constructor)member).isVarArgs(); } else { return false; } diff --git a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java index a9527b6f7..485aa0a76 100644 --- a/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java +++ b/weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java @@ -235,7 +235,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR return ret; } - private ResolvedMember createGenericConstructorMember(Constructor forConstructor) { + private ResolvedMember createGenericConstructorMember(Constructor forConstructor) { ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.METHOD, getGenericResolvedType(), forConstructor.getModifiers(), // to return what BCEL returns the return type is void @@ -268,7 +268,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR } else { parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader()); } - Set additionalPointcutHandlers = world.getRegisteredPointcutHandlers(); + Set additionalPointcutHandlers = world.getRegisteredPointcutHandlers(); for (Object additionalPointcutHandler : additionalPointcutHandlers) { PointcutDesignatorHandler handler = (PointcutDesignatorHandler) additionalPointcutHandler; parser.registerPointcutDesignatorHandler(handler); diff --git a/weaver/src/main/java/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver/src/main/java/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java index caf984821..be8123ebb 100644 --- a/weaver/src/main/java/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java +++ b/weaver/src/main/java/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java @@ -45,7 +45,7 @@ public class JavaLangTypeToResolvedTypeConverter { public ResolvedType fromType(Type type) { if (type instanceof Class) { - Class clazz = (Class) type; + Class clazz = (Class) type; String name = clazz.getName(); /** * getName() can return: @@ -87,7 +87,7 @@ public class JavaLangTypeToResolvedTypeConverter { if (inprogressVar != null) { return inprogressVar; } - java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) type; + java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) type; TypeVariable rt_tv = new TypeVariable(tv.getName()); TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld()); typeVariablesInProgress.put(type, tvrt); // record what we are working on, for recursion case diff --git a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java index 00346a0fb..f64fc87d5 100644 --- a/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java +++ b/weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java @@ -566,7 +566,7 @@ public class WeavingAdaptor implements IMessageContext { return wcp.getBytes(); } - private void registerAspectLibraries(List aspectPath) { + private void registerAspectLibraries(List aspectPath) { // System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")"); for (Object o : aspectPath) { String libName = (String) o; -- 2.39.5