From 2091b6d1ded90bfeb29f8d74bd17f05ec8fc983d Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Wed, 13 Apr 2022 13:51:39 +0300 Subject: Reduce 'Object' class usage --- .../ajdt/internal/compiler/lookup/AjLookupEnvironment.java | 3 ++- .../ajdt/internal/compiler/problem/AjProblemReporter.java | 2 +- .../org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java | 5 ++--- .../org/aspectj/ajdt/internal/core/builder/AjBuildManager.java | 10 ++++------ .../aspectj/ajdt/internal/core/builder/AjCompilerOptions.java | 2 +- .../java/org/aspectj/ajdt/internal/core/builder/AjState.java | 10 ++-------- .../ajdt/internal/core/builder/EmacsStructureModelManager.java | 4 ++-- .../aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java | 5 ++--- 8 files changed, 16 insertions(+), 25 deletions(-) (limited to 'org.aspectj.ajdt.core') diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java index b9bd7db86..6542ac828 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/AjLookupEnvironment.java @@ -68,6 +68,7 @@ import org.aspectj.weaver.bcel.BcelAnnotation; import org.aspectj.weaver.bcel.BcelObjectType; import org.aspectj.weaver.bcel.FakeAnnotation; import org.aspectj.weaver.bcel.LazyClassGen; +import org.aspectj.weaver.patterns.Declare; import org.aspectj.weaver.patterns.DeclareAnnotation; import org.aspectj.weaver.patterns.DeclareParents; @@ -757,7 +758,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC } } - List forRemoval = new ArrayList<>(); + List forRemoval = new ArrayList<>(); // now lets loop over and over until we have done all we can while ((anyNewAnnotations || anyNewParents) && (!decpToRepeat.isEmpty() || !decaToRepeat.isEmpty())) { anyNewParents = anyNewAnnotations = false; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java index e58810f91..9604bab9b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java @@ -489,7 +489,7 @@ public class AjProblemReporter extends ProblemReporter { AspectDeclaration ad = (AspectDeclaration) typeDecl.enclosingType; if (ad.concreteName != null) { List declares = ad.concreteName.declares; - for (Object dec : declares) { + for (Declare dec : declares) { if (dec instanceof DeclareParents) { DeclareParents decp = (DeclareParents) dec; TypePattern[] newparents = decp.getParents().getTypePatterns(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java index 4c319d549..3e526002e 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java @@ -536,9 +536,8 @@ public class AjBuildConfig implements CompilerConfigurationChangeFlags { setMakeReflectable(global.isMakeReflectable()); } - @SuppressWarnings({ "rawtypes", "unchecked" }) - void join(Collection local, Collection global) { - for (Object next : global) { + void join(Collection local, Collection global) { + for (T next : global) { if (!local.contains(next)) { local.add(next); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index 941b30105..4f45959df 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -678,14 +678,13 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } } - private ByteArrayOutputStream getOutxmlContents(List aspectNames) { + private ByteArrayOutputStream getOutxmlContents(List aspectNames) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); ps.println(""); ps.println(""); if (aspectNames != null) { - for (Object aspectName : aspectNames) { - String name = (String) aspectName; + for (String name : aspectNames) { ps.println(""); } } @@ -719,9 +718,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour } outputDirsToAspects.put(outputDir, aspectNames); } else { - List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations(); - for (Object dir : outputDirs) { - File outputDir = (File) dir; + List outputDirs = buildConfig.getCompilationResultDestinationManager().getAllOutputLocations(); + for (File outputDir : outputDirs) { outputDirsToAspects.put(outputDir, new ArrayList<>()); } if (aspectNamesToFileNames != null) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java index bd9842fca..95368d4bf 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjCompilerOptions.java @@ -152,7 +152,7 @@ public class AjCompilerOptions extends CompilerOptions { @Override public void set(Map optionsMap) { super.set(optionsMap); - Object optionValue; + String optionValue; if ((optionValue = optionsMap.get(OPTION_ReportUnusedPrivateMember)) != null) { updateSeverity(UnusedPrivateMember, optionValue); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java index a354e0d92..358b71f91 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -974,7 +974,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe * @param outputLocs the output locations that should be ignored if they occur on the paths being compared * @return true if a change is detected that requires a full build */ - private boolean changedAndNeedsFullBuild(List oldPath, List newPath, boolean checkClassFiles, List outputLocs, + private boolean changedAndNeedsFullBuild(List oldPath, List newPath, boolean checkClassFiles, List outputLocs, Set alreadyAnalysedPaths, int pathid) { if (oldPath.size() != newPath.size()) { return true; @@ -983,13 +983,7 @@ public class AjState implements CompilerConfigurationChangeFlags, TypeDelegateRe if (!oldPath.get(i).equals(newPath.get(i))) { return true; } - Object o = oldPath.get(i); // String on classpath, File on other paths - File f = null; - if (o instanceof String) { - f = new File((String) o); - } else { - f = (File) o; - } + File f = oldPath.get(i); if (f.exists() && !f.isDirectory() && (f.lastModified() >= lastSuccessfulBuildTime)) { return true; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java index 2de9f358a..41a6663fb 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java @@ -42,8 +42,8 @@ public class EmacsStructureModelManager { try { // Set fileSet = StructureModelManager.INSTANCE.getStructureModel().getFileMap().entrySet(); Set> fileSet = model.getHierarchy().getFileMapEntrySet(); - for (Object o : fileSet) { - IProgramElement peNode = (IProgramElement) ((Map.Entry) o).getValue(); + for (Map.Entry o : fileSet) { + IProgramElement peNode = o.getValue(); dumpStructureToFile(peNode); } } catch (IOException ioe) { diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java index dd5511fc9..6c465dd5b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjNaiveASTFlattener.java @@ -83,9 +83,8 @@ public class AjNaiveASTFlattener extends AjASTVisitor { * @param ext the list of modifier and annotation nodes * (element type: IExtendedModifiers) */ - void printModifiers(List ext) { - for (Object o : ext) { - ASTNode p = (ASTNode) o; + void printModifiers(List ext) { + for (ASTNode p : ext) { p.accept(this); this.buffer.append(" ");//$NON-NLS-1$ } -- cgit v1.2.3