]> source.dussan.org Git - aspectj.git/commitdiff
Cleanup redundant type casts, due to too weak variable type declaration 130/head
authorAndrey Turbanov <turbanoff@gmail.com>
Sat, 26 Feb 2022 11:17:56 +0000 (14:17 +0300)
committerAndrey Turbanov <turbanoff@gmail.com>
Sat, 26 Feb 2022 11:17:56 +0000 (14:17 +0300)
17 files changed:
ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java
ajde/src/main/java/org/aspectj/ajde/ui/BuildConfigModel.java
ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java
org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java
runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java
weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java
weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java
weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java

index 5a90fe77b44311e4cb5f6ef04b9bf1fdd34299fa..e775810c3f07e894b97389814e08c48a51460820 100644 (file)
@@ -276,8 +276,8 @@ public class LstBuildConfigManager implements BuildConfigManager {
        }
 
        private void notifyConfigChanged() {
-               for (Object element : listeners) {
-                       ((BuildConfigListener) element).currConfigChanged(currConfigFilePath);
+               for (BuildConfigListener element : listeners) {
+                       element.currConfigChanged(currConfigFilePath);
                }
        }
 
index 31b64fb2ad53b5e76439238624e9cfb8f9d1776b..eadda238964914f91723b2d79799b945811f7b7f 100644 (file)
@@ -112,8 +112,8 @@ public class BuildConfigModel {
                }
 
                if (node != null && node.getChildren() != null) {
-                       for (Object element : node.getChildren()) {
-                               BuildConfigNode foundNode = findNodeForSourceLineHelper((BuildConfigNode) element, sourceFilePath, lineNumber);
+                       for (BuildConfigNode element : node.getChildren()) {
+                               BuildConfigNode foundNode = findNodeForSourceLineHelper(element, sourceFilePath, lineNumber);
                                if (foundNode != null)
                                        return foundNode;
                        }
index 6def17bd62f5a5ad8084d0ac27bb8af7b49c74ce..8348681c67fc303dd8fdd62c60f666e26abd7921 100644 (file)
@@ -125,8 +125,7 @@ public class TreeStructureViewBuilder {
                        }
                }
                if (node.getChildren() != null) {
-                       for (Object element : node.getChildren()) {
-                               IProgramElement IProgramElement = (IProgramElement)element;
+                       for (IProgramElement IProgramElement : node.getChildren()) {
                                if (acceptNode(IProgramElement, properties)) {
                                        children.add(createViewNode(IProgramElement, properties));
                                }
index aba047974890c6d41536534496a1a26e89abeef8..ed0b9aa69dd178fac85b1f13287fdacd04e7ca01 100644 (file)
@@ -95,11 +95,10 @@ public class EmacsStructureModelManager {
 
                private void printDecls(IProgramElement node) {
                        print("(");
-                       for (Object nodeObject : node.getChildren()) {
+                       for (IProgramElement child : node.getChildren()) {
                                // this ignores relations on the compile unit
                                // throw new RuntimeException("unimplemented");
                                // if (nodeObject instanceof IProgramElement) {
-                               IProgramElement child = (IProgramElement) nodeObject;
                                printDecl(child, true);
                                // }
                                // else if (nodeObject instanceof LinkNode) {
@@ -179,13 +178,10 @@ public class EmacsStructureModelManager {
                                if (it3.hasNext()) {
                                        while (it3.hasNext()) {
                                                // this ignores relations on the compile unit
-                                               Object nodeObject = it3.next();
-                                               if (nodeObject instanceof IProgramElement) {
-                                                       IProgramElement currNode = (IProgramElement) nodeObject;
-                                                       if (// !currNode.isStmntKind() &&
-                                                       !currNode.getKind().equals("<undefined>")) {
-                                                               printDecl(currNode, true);
-                                                       }
+                                               IProgramElement currNode = it3.next();
+                                               if (// !currNode.isStmntKind() &&
+                                               !currNode.getKind().equals("<undefined>")) {
+                                                       printDecl(currNode, true);
                                                }
                                        }
                                }
index c38fbd96e5cc11bbc66fa4c0afff550255607bfd..bc4904bd76f1a54542d61c762b7d0de48cd5a3ac 100644 (file)
@@ -658,10 +658,10 @@ public class AjASTConverter extends ASTConverter {
                } else if (declare instanceof DeclareParents) {
                        DeclareParents dp = (DeclareParents) declare;
                        declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast, dp.isExtends());
-                       org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(dp.getChild());
+                       AbstractTypePattern pNode = convert(dp.getChild());
                        if (pNode instanceof AbstractTypePattern) {
                                ((DeclareParentsDeclaration) declareDeclaration)
-                                               .setChildTypePattern((AbstractTypePattern) pNode);
+                                               .setChildTypePattern(pNode);
                        }
                        TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns();
                        List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns();
@@ -680,10 +680,10 @@ public class AjASTConverter extends ASTConverter {
                        declareDeclaration = new DeclareSoftDeclaration(this.ast);
                        DeclareSoft ds = (DeclareSoft) declare;
                        ((DeclareSoftDeclaration) declareDeclaration).setPointcut(convert(ds.getPointcut()));
-                       org.aspectj.org.eclipse.jdt.core.dom.PatternNode pNode = convert(ds.getException());
+                       AbstractTypePattern pNode = convert(ds.getException());
                        if (pNode instanceof AbstractTypePattern) {
                                ((DeclareSoftDeclaration) declareDeclaration)
-                                               .setTypePattern((AbstractTypePattern) pNode);
+                                               .setTypePattern(pNode);
                        }
                }
 
index 98480f661565b825ec30b4680b1c396c6fe96646..6bfd8a8973eb7b005fa49881cee03361a344b708 100644 (file)
@@ -343,25 +343,15 @@ public class CrosscuttingMembers {
                Set<Object> theseTypeMungers = new HashSet<>();
                Set<Object> otherTypeMungers = new HashSet<>();
                if (!careAboutShadowMungers) {
-                       for (Object o : typeMungers) {
-                               if (o instanceof ConcreteTypeMunger) {
-                                       ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) o;
-                                       if (!typeMunger.existsToSupportShadowMunging()) {
-                                               theseTypeMungers.add(typeMunger);
-                                       }
-                               } else {
-                                       theseTypeMungers.add(o);
+                       for (ConcreteTypeMunger typeMunger : typeMungers) {
+                               if (!typeMunger.existsToSupportShadowMunging()) {
+                                       theseTypeMungers.add(typeMunger);
                                }
                        }
 
-                       for (Object o : other.typeMungers) {
-                               if (o instanceof ConcreteTypeMunger) {
-                                       ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) o;
-                                       if (!typeMunger.existsToSupportShadowMunging()) {
-                                               otherTypeMungers.add(typeMunger);
-                                       }
-                               } else {
-                                       otherTypeMungers.add(o);
+                       for (ConcreteTypeMunger typeMunger : other.typeMungers) {
+                               if (!typeMunger.existsToSupportShadowMunging()) {
+                                       otherTypeMungers.add(typeMunger);
                                }
                        }
                } else {
index 5f7cd15538147dab6e4332a9f66d528dda32a00b..6742e9091612a75aa971c7558c0669863aac1840 100644 (file)
@@ -140,8 +140,7 @@ public class AnnotationPointcut extends NameBindingPointcut {
                                if (kind == Shadow.FieldGet || kind == Shadow.FieldSet) {
                                        // FIXME asc should include supers with getInterTypeMungersIncludingSupers ?
                                        List<ConcreteTypeMunger> mungers = rMember.getDeclaringType().resolve(shadow.getIWorld()).getInterTypeMungers();
-                                       for (Object munger : mungers) {
-                                               ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) munger;
+                                       for (ConcreteTypeMunger typeMunger : mungers) {
                                                if (typeMunger.getMunger() instanceof NewFieldTypeMunger) {
                                                        ResolvedMember fakerm = typeMunger.getSignature();
                                                        if (fakerm.equals(member)) {
index 9565230dd8db6d56ddaa1d3c775d1d2f1fcce310..5c4c5423a1e334bc1e57ad6dfe8411a6ac0c0763 100644 (file)
@@ -148,8 +148,7 @@ public class StandardPointcutParser {
         */
        private StandardPointcutParser(Set<PointcutPrimitive> supportedPointcutKinds, World world) {
                supportedPrimitives = supportedPointcutKinds;
-               for (Object supportedPointcutKind : supportedPointcutKinds) {
-                       PointcutPrimitive element = (PointcutPrimitive) supportedPointcutKind;
+               for (PointcutPrimitive element : supportedPointcutKinds) {
                        if ((element == PointcutPrimitive.IF) || (element == PointcutPrimitive.CFLOW)
                                        || (element == PointcutPrimitive.CFLOW_BELOW)) {
                                throw new UnsupportedOperationException("Cannot handle if, cflow, and cflowbelow primitives");
index b040dfd19695a413ac8d89488e7fe3334e88bc5a..6f6a51bd9e940483316f816bd8adaec81141d980 100644 (file)
@@ -48,8 +48,7 @@ public class ThreadCounterImpl11 implements ThreadCounter {
                                        Thread t = (Thread)e.nextElement();
                                        if (!t.isAlive()) dead_stacks.add(t);
                                }
-                               for (Object dead_stack : dead_stacks) {
-                                       Thread t = (Thread) dead_stack;
+                               for (Thread t : dead_stacks) {
                                        counters.remove(t);
                                }
                                change_count = 0;
index 87f2f4423ada9b79415061bfad75cc9aa39bf6e4..9215efb23d668d72fc28a9f90b767d112a5362b2 100644 (file)
@@ -414,8 +414,8 @@ public class Ajc2 extends Javac {
         List<File> newIncludes = new ArrayList<>();
         List<String> newArguments = new ArrayList<>();
         if (argfiles != null) {
-                       for (Object o : argfiles) {
-                               File argfile = ((Argfile) o).getFile();
+                       for (Argfile o : argfiles) {
+                               File argfile = o.getFile();
                                expandArgfile(argfile, newIncludes, newArguments);
                        }
         }
@@ -442,8 +442,8 @@ public class Ajc2 extends Javac {
         }
 
         // Add the new included files
-               for (Object newInclude : newIncludes) {
-                       newFiles.add((File) newInclude);
+               for (File newInclude : newIncludes) {
+                       newFiles.add(newInclude);
                }
 
         // This is the same behavior found in Javac
index aa9bd33a4fc7543aaa03051d5d241da91e438b6a..e49580dbe262d2bee499bb119b5c7384277ab665 100644 (file)
@@ -1570,8 +1570,7 @@ public class AjcTask extends MatchingTask {
                        }
                }
                if (0 < adapterFiles.size()) {
-            for (Object adapterFile : adapterFiles) {
-                File file = (File) adapterFile;
+            for (File file : adapterFiles) {
                 if (file.canRead() && FileUtil.hasSourceSuffix(file)) {
                     list.add(file.getAbsolutePath());
                 }
index 9640fe11816ff24b3bc45f65568f23a93ec90cdd..d814903c9d4b2bf33b2c4fca79615b49c2735828 100644 (file)
@@ -1510,8 +1510,7 @@ public class BcelShadow extends Shadow {
                if (foundMember == null) {
                        // check the ITD'd dooberries
                        List<ConcreteTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers();
-                       for (Object munger : mungers) {
-                               ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) munger;
+                       for (ConcreteTypeMunger typeMunger : mungers) {
                                if (typeMunger.getMunger() instanceof NewMethodTypeMunger
                                                || typeMunger.getMunger() instanceof NewConstructorTypeMunger) {
                                        ResolvedMember fakerm = typeMunger.getSignature();
index 53f71df5689d978d7e036eeaf1b67f9fa3e3bbaa..ccea81f49f21e86a1c513d5c0f555675b4614051 100644 (file)
@@ -1257,8 +1257,7 @@ public class BcelWeaver {
                        List<ShadowMunger> l = world.getCrosscuttingMembersSet().getShadowMungers();
                        Set<AdviceLocation> alreadyWarnedLocations = new HashSet<>();
 
-                       for (Object o : l) {
-                               ShadowMunger element = (ShadowMunger) o;
+                       for (ShadowMunger element : l) {
                                // This will stop us incorrectly reporting deow checkers:
                                if (element instanceof BcelAdvice) {
                                        BcelAdvice ba = (BcelAdvice) element;
index 9155b4ba02c66484c8edb64297e7a93bc5cc7567..3feadca38f3589065fa6f631fd8ec65cf75febd6 100644 (file)
@@ -165,9 +165,8 @@ public final class LazyClassGen {
        }
 
        void addInlinedSourceFileInfo(String fullpath, int highestLineNumber) {
-               Object o = inlinedFiles.get(fullpath);
-               if (o != null) {
-                       InlinedSourceFileInfo info = (InlinedSourceFileInfo) o;
+               InlinedSourceFileInfo info = inlinedFiles.get(fullpath);
+               if (info != null) {
                        if (info.highestLineNumber < highestLineNumber) {
                                info.highestLineNumber = highestLineNumber;
                        }
index 223d2c4321c9720f3c1381990dc45b6df788251b..5aaec2e7097c85cc77214a14725f6a08586bfc02 100644 (file)
@@ -254,8 +254,7 @@ public class SimpleAOPParser {
                        throws Exception {
                sap.startElement(xml.getName(), xml.getAttributes());
                Iterable<LightXMLParser> childrens = xml.getChildrens();
-               for (Object children : childrens) {
-                       LightXMLParser child = (LightXMLParser) children;
+               for (LightXMLParser child : childrens) {
                        traverse(sap, child);
                }
                sap.endElement(xml.getName());
index 485aa0a7647afba546885c1ab407d0ea553b100d..c574e9196a536f0a593d16fbf66e60f092513568 100644 (file)
@@ -269,8 +269,7 @@ public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedR
                                parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader());
                        }
                        Set<PointcutDesignatorHandler> additionalPointcutHandlers = world.getRegisteredPointcutHandlers();
-                       for (Object additionalPointcutHandler : additionalPointcutHandlers) {
-                               PointcutDesignatorHandler handler = (PointcutDesignatorHandler) additionalPointcutHandler;
+                       for (PointcutDesignatorHandler handler : additionalPointcutHandlers) {
                                parser.registerPointcutDesignatorHandler(handler);
                        }
 
index f64fc87d5d4af359b8654eab4dd7898a1348bac2..3ce3eef6ea739d853876393bff4bb1bbd34d200a 100644 (file)
@@ -568,8 +568,7 @@ public class WeavingAdaptor implements IMessageContext {
 
        private void registerAspectLibraries(List<String> aspectPath) {
                // System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")");
-               for (Object o : aspectPath) {
-                       String libName = (String) o;
+               for (String libName : aspectPath) {
                        addAspectLibrary(libName);
                }