diff options
author | Andrey Turbanov <turbanoff@gmail.com> | 2022-04-12 11:22:29 +0300 |
---|---|---|
committer | Andrey Turbanov <turbanoff@gmail.com> | 2022-04-12 11:22:29 +0300 |
commit | 1c487b2e0f54eeb4c2630940e7d57c279ba5a032 (patch) | |
tree | 0c0d84e75783441de07f4193e003429e64b11550 /org.aspectj.ajdt.core | |
parent | caa2c39be10775a8772a27eea8b9a673dd0bab8d (diff) | |
download | aspectj-1c487b2e0f54eeb4c2630940e7d57c279ba5a032.tar.gz aspectj-1c487b2e0f54eeb4c2630940e7d57c279ba5a032.zip |
Remove redundant casts after generics update
Diffstat (limited to 'org.aspectj.ajdt.core')
13 files changed, 38 insertions, 46 deletions
diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java index fe1097c9c..202abcadd 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/ajc/BuildArgParser.java @@ -400,8 +400,7 @@ public class BuildArgParser extends Main { if (parser.classpath == null) { addClasspath(System.getProperty("java.class.path", ""), ret); List<String> fixedList = new ArrayList<>(); - for (Object o : ret) { - String entry = (String) o; + for (String entry : ret) { if (!entry.endsWith("aspectjtools.jar")) { fixedList.add(entry); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java index b56518dc9..bfa98334d 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/AjCompilerAdapter.java @@ -273,8 +273,7 @@ public class AjCompilerAdapter extends AbstractCompilerAdapter { private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<UnwovenClassFile>> binarySourceEntries) { // Map is fileName |-> List<UnwovenClassFile> List<InterimCompilationResult> ret = new ArrayList<>(); - for (Object o : binarySourceEntries.keySet()) { - String sourceFileName = (String) o; + for (String sourceFileName : binarySourceEntries.keySet()) { List<UnwovenClassFile> unwovenClassFiles = binarySourceEntries.get(sourceFileName); // XXX - see bugs 57432,58679 - final parameter on next call should be "compiler.options.maxProblemsPerUnit" CompilationResult result = new CompilationResult(sourceFileName.toCharArray(), 0, 0, Integer.MAX_VALUE); @@ -286,16 +285,14 @@ public class AjCompilerAdapter extends AbstractCompilerAdapter { } private void notifyRequestor() { - for (Object o : resultsPendingWeave) { - InterimCompilationResult iresult = (InterimCompilationResult) o; + for (InterimCompilationResult iresult : resultsPendingWeave) { compiler.requestor.acceptResult(iresult.result().tagAsAccepted()); } } private void weave() throws IOException { // ensure weaver state is set up correctly - for (Object o : resultsPendingWeave) { - InterimCompilationResult iresult = (InterimCompilationResult) o; + for (InterimCompilationResult iresult : resultsPendingWeave) { for (int i = 0; i < iresult.unwovenClassFiles().length; i++) { weaver.addClassFile(iresult.unwovenClassFiles()[i], false); } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java index 8d7277524..629eb8edb 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverAdapter.java @@ -93,13 +93,13 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera if (nowProcessing == null) { if (!resultIterator.hasNext()) return false; - nowProcessing = (InterimCompilationResult) resultIterator.next(); + nowProcessing = resultIterator.next(); classFileIndex = 0; } while (nowProcessing.unwovenClassFiles().length == 0) { if (!resultIterator.hasNext()) return false; - nowProcessing = (InterimCompilationResult) resultIterator.next(); + nowProcessing = resultIterator.next(); } if (classFileIndex < nowProcessing.unwovenClassFiles().length) { return true; @@ -107,11 +107,11 @@ public class WeaverAdapter implements IClassFileProvider, IWeaveRequestor, Itera classFileIndex = 0; if (!resultIterator.hasNext()) return false; - nowProcessing = (InterimCompilationResult) resultIterator.next(); + nowProcessing = resultIterator.next(); while (nowProcessing.unwovenClassFiles().length == 0) { if (!resultIterator.hasNext()) return false; - nowProcessing = (InterimCompilationResult) resultIterator.next(); + nowProcessing = resultIterator.next(); } } return true; diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java index 951e33caa..fc6bb9042 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java @@ -211,8 +211,7 @@ public class WeaverMessageHandler implements IMessageHandler { boolean usedBinarySourceFileName) { List<IProblem> ret = new ArrayList<>(); - for (Object sourceLocation : sourceLocations) { - ISourceLocation loc = (ISourceLocation) sourceLocation; + for (ISourceLocation loc : sourceLocations) { if (loc != null) { DefaultProblem dp = new DefaultProblem(loc.getSourceFile().getPath().toCharArray(), "see also", 0, new String[]{}, ProblemSeverities.Ignore, getStartPos(loc, null), getEndPos(loc, null), loc.getLine(), loc.getColumn()); @@ -229,7 +228,7 @@ public class WeaverMessageHandler implements IMessageHandler { ProblemSeverities.Ignore, 0, 0, 0, 0); ret.add(dp); } - IProblem[] retValue = (IProblem[]) ret.toArray(new IProblem[] {}); + IProblem[] retValue = ret.toArray(new IProblem[] {}); return retValue; } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java index b71eddae9..8e06a586c 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AccessForInlineVisitor.java @@ -237,7 +237,7 @@ public class AccessForInlineVisitor extends ASTVisitor { ResolvedMember m = world.makeResolvedMember(binding); ResolvedMember superAccessMember = AjcMemberMaker.superAccessMethod(inAspect.typeX, m); if (inAspect.superAccessForInline.containsKey(superAccessMember)) { - return ((SuperAccessMethodPair) inAspect.superAccessForInline.get(superAccessMember)).accessMethod; + return inAspect.superAccessForInline.get(superAccessMember).accessMethod; } MethodBinding ret = world.makeMethodBinding(superAccessMember); inAspect.superAccessForInline.put(superAccessMember, new SuperAccessMethodPair(m, ret)); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java index 709fc1597..b085a0362 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/DeclareDeclaration.java @@ -77,7 +77,7 @@ public class DeclareDeclaration extends AjMethodDeclaration { Collection<UnresolvedType> parentPatterns = dp.getParents().getExactTypes(); StringBuilder parents = new StringBuilder(); for (Iterator<UnresolvedType> iter = parentPatterns.iterator(); iter.hasNext();) { - UnresolvedType urt = ((UnresolvedType) iter.next()); + UnresolvedType urt = iter.next(); parents.append(urt.getName()); if (iter.hasNext()) { parents.append(", "); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java index f96fb3579..8a63b153f 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/ValidateAtAspectJAnnotationsVisitor.java @@ -214,7 +214,7 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { private boolean insideAspect() { if (typeStack.empty()) return false; - TypeDeclaration typeDecl = (TypeDeclaration) typeStack.peek(); + TypeDeclaration typeDecl = typeStack.peek(); return isAspect(typeDecl); } @@ -401,8 +401,8 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { UnresolvedType[] paramTypes = new UnresolvedType[bindings.length]; for (int i = 0; i < paramTypes.length; i++) paramTypes[i] = bindings[i].getType(); - ResolvedPointcutDefinition resPcutDef = new ResolvedPointcutDefinition(factory.fromBinding(((TypeDeclaration) typeStack - .peek()).binding), methodDeclaration.modifiers, "anonymous", paramTypes, pc); + ResolvedPointcutDefinition resPcutDef = new ResolvedPointcutDefinition(factory.fromBinding(typeStack.peek().binding), + methodDeclaration.modifiers, "anonymous", paramTypes, pc); AjAttribute attr = new AjAttribute.PointcutDeclarationAttribute(resPcutDef); ((AjMethodDeclaration) methodDeclaration).addAttribute(new EclipseAttributeAdapter(attr)); } catch (ParserException pEx) { @@ -500,7 +500,7 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { } private void convertToPointcutDeclaration(MethodDeclaration methodDeclaration, ClassScope scope) { - TypeDeclaration typeDecl = (TypeDeclaration) typeStack.peek(); + TypeDeclaration typeDecl = typeStack.peek(); if (typeDecl.binding != null) { if (!typeDecl.binding.isClass()) { methodDeclaration.scope.problemReporter().signalError(methodDeclaration.sourceStart, methodDeclaration.sourceEnd, @@ -547,7 +547,7 @@ public class ValidateAtAspectJAnnotationsVisitor extends ASTVisitor { } pcDecl.pointcutDesignator = (pc == null) ? null : new PointcutDesignator(pc); pcDecl.setGenerateSyntheticPointcutMethod(); - TypeDeclaration onType = (TypeDeclaration) typeStack.peek(); + TypeDeclaration onType = typeStack.peek(); pcDecl.postParse(onType); // EclipseFactory factory = // EclipseFactory.fromScopeLookupEnvironment 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 e8d99b4f9..b9bd7db86 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 @@ -699,9 +699,8 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC // Check if the type we are looking at is the topMostImplementor of a // dangerous interface - // report a problem if it is. - for (Object o : dangerousInterfaces.entrySet()) { - Map.Entry<ResolvedType, String> entry = (Map.Entry) o; - ResolvedType interfaceType = (ResolvedType) entry.getKey(); + for (Map.Entry<ResolvedType, String> entry : dangerousInterfaces.entrySet()) { + ResolvedType interfaceType = entry.getKey(); if (onType.isTopmostImplementor(interfaceType)) { factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null); } @@ -1442,7 +1441,7 @@ public class AjLookupEnvironment extends LookupEnvironment implements AnonymousC if (pendingTypesToFinish.size() > 0) { processingTheQueue = true; while (!pendingTypesToFinish.isEmpty()) { - BinaryTypeBinding nextVictim = (BinaryTypeBinding) pendingTypesToFinish.remove(0); + BinaryTypeBinding nextVictim = pendingTypesToFinish.remove(0); // During this call we may recurse into this method and add // more entries to the pendingTypesToFinish list. weaveInterTypeDeclarations(nextVictim); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java index fd36f61fb..ad9e8374b 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/lookup/PrivilegedHandler.java @@ -143,8 +143,8 @@ public class PrivilegedHandler implements IPrivilegedHandler { int len = m.size(); ResolvedMember[] ret = new ResolvedMember[len]; int index = 0; - for (Object o : m) { - ret[index++] = (ResolvedMember) o; + for (ResolvedMember o : m) { + ret[index++] = o; } return ret; } 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 b1ae347ba..e58810f91 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 @@ -564,8 +564,7 @@ public class AjProblemReporter extends ProblemReporter { Collection<ResolvedMember> privvies = ((ReferenceType) theAspect).getPrivilegedAccesses(); // On an incremental compile the information is in the bcel delegate if (privvies != null) { - for (Object privvy : privvies) { - ResolvedMember priv = (ResolvedMember) privvy; + for (ResolvedMember priv : privvies) { if (priv.getName().equals(fname)) { return; } 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 84569d4df..941b30105 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 @@ -734,7 +734,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider, IBinarySour if (!outputDirsToAspects.containsKey(outputDir)) { outputDirsToAspects.put(outputDir, new ArrayList<>()); } - ((List) outputDirsToAspects.get(outputDir)).add(aspectName); + outputDirsToAspects.get(outputDir).add(aspectName); } } } diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java index c36afd3ec..9410f1806 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java @@ -172,7 +172,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { // -- remove duplicates before adding (XXX use them instead?) if (addToNode != null && addToNode.getChildren() != null) { for (ListIterator<IProgramElement> itt = addToNode.getChildren().listIterator(); itt.hasNext();) { - IProgramElement child = (IProgramElement) itt.next(); + IProgramElement child = itt.next(); ISourceLocation childLoc = child.getSourceLocation(); if (null == childLoc) { // XXX ok, packages have null source locations @@ -413,7 +413,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { peNode.setFormalComment(generateJavadocComment(memberTypeDeclaration)); peNode.setAnnotationStyleDeclaration(isAnnotationStyleAspect); - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); stack.push(peNode); return true; } @@ -482,11 +482,11 @@ public class AsmHierarchyBuilder extends ASTVisitor { } } - IProgramElement ipe = (IProgramElement)stack.peek(); + IProgramElement ipe = stack.peek(); if (ipe!=null) { // With AspectJ 1.8.9 the type structure must be slightly different as the guard // is required (the null is due to a default constructor). - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); } stack.push(peNode); return true; @@ -597,7 +597,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { .equals("main(java.lang.String[])")) && peNode.getModifiers().contains(IProgramElement.Modifiers.STATIC) && peNode.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC)) { - ((IProgramElement) stack.peek()).setRunnable(true); + stack.peek().setRunnable(true); } } @@ -763,7 +763,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { npe.printStackTrace(); } } - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); } public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) { @@ -791,7 +791,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { // create Source signature for import peNode.setSourceSignature(genSourceSignature(importRef)); - IProgramElement containingTypeElement = (IProgramElement) stack.peek(); + IProgramElement containingTypeElement = stack.peek(); ProgramElement imports = getImportReferencesRoot(); imports.addChild(0, peNode); stack.push(peNode); @@ -800,7 +800,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { } private ProgramElement getImportReferencesRoot() { - IProgramElement element = (IProgramElement) stack.peek(); + IProgramElement element = stack.peek(); boolean hasPackageDeclaration = (element.getChildren().get(0)).getKind().isPackageDeclaration(); return (ProgramElement) element.getChildren().get(hasPackageDeclaration ? 1 : 0); } @@ -870,7 +870,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { peNode.setFormalComment(generateJavadocComment(fieldDeclaration)); // peNode.setBytecodeSignature(new String(fieldDeclaration.binding.type.signature())); - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); stack.push(peNode); return true; } @@ -1022,7 +1022,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { peNode.setBytecodeSignature(memberBytecodeSignature); } - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); stack.push(peNode); return true; } @@ -1101,7 +1101,7 @@ public class AsmHierarchyBuilder extends ASTVisitor { makeLocation(initializer), initializer.modifiers, null, null); // "", // new ArrayList()); - ((IProgramElement) stack.peek()).addChild(peNode); + stack.peek().addChild(peNode); stack.push(peNode); initializer.block.traverse(this, scope); stack.pop(); diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java index 1a4f3ffef..31ec56ab0 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/IncrementalStateManager.java @@ -58,7 +58,7 @@ public class IncrementalStateManager { System.out.println("Name " + entry.getKey()); File f = new File("n:/temp/foo.ajstate"); try { - AjState state = (AjState) entry.getValue(); + AjState state = entry.getValue(); CompressingDataOutputStream dos = new CompressingDataOutputStream(new FileOutputStream(f)); state.write(dos); dos.close(); @@ -87,7 +87,7 @@ public class IncrementalStateManager { } public static AjState retrieveStateFor(String configFile) { - return (AjState) incrementalStates.get(configFile); + return incrementalStates.get(configFile); } // now, managing changes to entries on a classpath @@ -117,8 +117,7 @@ public class IncrementalStateManager { CompilationResultDestinationManager outputManager = ajbc.getCompilationResultDestinationManager(); if (outputManager != null) { List<File> outputDirs = outputManager.getAllOutputLocations(); - for (Object o : outputDirs) { - File dir = (File) o; + for (File dir : outputDirs) { if (dir.equals(location)) { if (debugIncrementalStates) { System.err.println("< findStateManagingOutputLocation(" + location + ") returning " + element); |