Skip to content

Commit

Permalink
Remove redundant casts after generics update
Browse files Browse the repository at this point in the history
  • Loading branch information
turbanoff committed Apr 12, 2022
1 parent caa2c39 commit 1c487b2
Show file tree
Hide file tree
Showing 50 changed files with 99 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private void createWarningsEntry(String labelText, String javaOptionToSet) {
panel.add(label,BorderLayout.WEST);

JComboBox warnings = new JComboBox(ignoreOrWarning);
String value = (String) javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet);
String value = javaBuildOptions.getJavaBuildOptionsMap().get(javaOptionToSet);
if (value.equals(JavaOptions.IGNORE)) {
warnings.setSelectedIndex(0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private void createOtherContents() {
characterEncoding.setPreferredSize(new Dimension(150, 21));
panel.add(characterEncoding,BorderLayout.EAST);

String option = (String) javaBuildOptions.getJavaBuildOptionsMap().get(
String option = javaBuildOptions.getJavaBuildOptionsMap().get(
JavaOptions.CHARACTER_ENCODING);
if (option != null) {
characterEncoding.setText(option);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static List<String> getDeclareTargets(IProgramElement node) {

public static String getPackageDeclarationFromFile(AsmManager model, File file) {
IProgramElement fileNode = model.getHierarchy().findElementForSourceFile(file.getAbsolutePath());
String packageName = ((IProgramElement) fileNode.getChildren().get(0)).getPackageName();
String packageName = fileNode.getChildren().get(0).getPackageName();
return packageName;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ public static String genSignature(IProgramElement node) {
for (int i = 0; i < node.getParameterTypes().size(); i++) {
sb.append(String.valueOf(node.getParameterTypes().get(i)));
sb.append(' ');
sb.append((String) node.getParameterNames().get(i));
sb.append(node.getParameterNames().get(i));
if (i < node.getParameterTypes().size() - 1) {
sb.append(", ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ public final class SwitchBuilder {
* @param max_gap maximum gap that may between case branches
*/
public SwitchBuilder(int[] match, InstructionHandle[] targets,InstructionHandle target, int max_gap) {
this.match = (int[])match.clone();
this.targets = (InstructionHandle[])targets.clone();
this.match = match.clone();
this.targets = targets.clone();

if((match_length = match.length) < 2) // (almost) empty switch, or just default
if (match.length==0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Module getModule(String name) {
if (null == name) {
return null;
}
Module result = (Module) modules.get(name);
Module result = modules.get(name);
if (null == result) {
File moduleDir = new File(baseDir, name);
if (!Util.canReadDir(moduleDir)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,7 @@ public List getClasspath(AjcConfigParser parser) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ public void acceptResult(CompilationResult result) {
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);
Expand All @@ -286,16 +285,14 @@ private List<InterimCompilationResult> getBinarySourcesFrom(Map<String, List<Unw
}

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ public boolean hasNext() {
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;
} else {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List<ISourceLo
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());
Expand All @@ -229,7 +228,7 @@ private IProblem[] buildSeeAlsoProblems(IProblem originalProblem, List<ISourceLo
ProblemSeverities.Ignore, 0, 0, 0, 0);
ret.add(dp);
}
IProblem[] retValue = (IProblem[]) ret.toArray(new IProblem[] {});
IProblem[] retValue = ret.toArray(new IProblem[] {});
return retValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private MethodBinding getSuperAccessMethod(MethodBinding binding) {
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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void addAtAspectJAnnotations() {
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(", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
private boolean insideAspect() {
if (typeStack.empty())
return false;
TypeDeclaration typeDecl = (TypeDeclaration) typeStack.peek();
TypeDeclaration typeDecl = typeStack.peek();
return isAspect(typeDecl);
}

Expand Down Expand Up @@ -401,8 +401,8 @@ private void resolveAndSetPointcut(MethodDeclaration methodDeclaration, Annotati
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) {
Expand Down Expand Up @@ -500,7 +500,7 @@ private String getStringLiteralFor(String memberName, Annotation inAnnotation, i
}

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,
Expand Down Expand Up @@ -547,7 +547,7 @@ private void convertToPointcutDeclaration(MethodDeclaration methodDeclaration, C
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,8 @@ private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, List<Concr
// 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);
}
Expand Down Expand Up @@ -1442,7 +1441,7 @@ public BinaryTypeBinding createBinaryTypeFrom(IBinaryType binaryType, PackageBin
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public ResolvedMember[] getMembers() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,7 @@ public void unusedPrivateField(FieldDeclaration fieldDecl) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ private Map<File, List<String>> findOutputDirsForAspects() {
if (!outputDirsToAspects.containsKey(outputDir)) {
outputDirsToAspects.put(outputDir, new ArrayList<>());
}
((List) outputDirsToAspects.get(outputDir)).add(aspectName);
outputDirsToAspects.get(outputDir).add(aspectName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private void internalBuild(CompilationUnitDeclaration unit, AsmManager structure
// -- 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
Expand Down Expand Up @@ -413,7 +413,7 @@ public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope scope) {
peNode.setFormalComment(generateJavadocComment(memberTypeDeclaration));
peNode.setAnnotationStyleDeclaration(isAnnotationStyleAspect);

((IProgramElement) stack.peek()).addChild(peNode);
stack.peek().addChild(peNode);
stack.push(peNode);
return true;
}
Expand Down Expand Up @@ -482,11 +482,11 @@ public boolean visit(TypeDeclaration memberTypeDeclaration, BlockScope scope) {
}
}

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;
Expand Down Expand Up @@ -597,7 +597,7 @@ public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
.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);
}
}

Expand Down Expand Up @@ -763,7 +763,7 @@ protected void genBytecodeInfo(MethodDeclaration methodDeclaration, IProgramElem
npe.printStackTrace();
}
}
((IProgramElement) stack.peek()).addChild(peNode);
stack.peek().addChild(peNode);
}

public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
Expand Down Expand Up @@ -791,7 +791,7 @@ IProgramElement.Kind.IMPORT_REFERENCE, makeLocation(importRef), 0,// could set s
// 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);
Expand All @@ -800,7 +800,7 @@ IProgramElement.Kind.IMPORT_REFERENCE, makeLocation(importRef), 0,// could set s
}

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);
}
Expand Down Expand Up @@ -870,7 +870,7 @@ public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) {
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;
}
Expand Down Expand Up @@ -1022,7 +1022,7 @@ IProgramElement.Kind.CONSTRUCTOR, makeLocation(constructorDeclaration), construc
peNode.setBytecodeSignature(memberBytecodeSignature);
}

((IProgramElement) stack.peek()).addChild(peNode);
stack.peek().addChild(peNode);
stack.push(peNode);
return true;
}
Expand Down Expand Up @@ -1101,7 +1101,7 @@ public boolean visit(Initializer initializer, MethodScope scope) {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static void persist() {
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();
Expand Down Expand Up @@ -87,7 +87,7 @@ public static Set getConfigFilesKnown() {
}

public static AjState retrieveStateFor(String configFile) {
return (AjState) incrementalStates.get(configFile);
return incrementalStates.get(configFile);
}

// now, managing changes to entries on a classpath
Expand Down Expand Up @@ -117,8 +117,7 @@ public static AjState findStateManagingOutputLocation(File location) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,8 @@ private void setFromProperties(InputStream s) throws IOException {
setFromProperties(p);
}

@SuppressWarnings("rawtypes")
public void setFromProperties(Properties properties) {
for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) {
Map.Entry entry = (Map.Entry) objectObjectEntry;
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
Kind kind = kinds.get(entry.getKey());
if (kind == null) {
MessageUtil.error(world.getMessageHandler(), WeaverMessages.format(WeaverMessages.XLINT_KEY_ERROR, entry.getKey()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ public void setDelegate(ReferenceTypeDelegate delegate) {
// If we are raw, we have a generic type - we should ensure it uses the
// same delegate
if (isRawType() && getGenericType() != null) {
ReferenceType genType = (ReferenceType) getGenericType();
ReferenceType genType = getGenericType();
if (genType.getDelegate() != delegate) { // avoids circular updates
genType.setDelegate(delegate);
}
Expand Down
Loading

0 comments on commit 1c487b2

Please sign in to comment.