Browse Source

Cleanup redundant type casts, due to too weak variable type declaration

tags/V1_9_9
Andrey Turbanov 2 years ago
parent
commit
2301b36776
17 changed files with 35 additions and 60 deletions
  1. 2
    2
      ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java
  2. 2
    2
      ajde/src/main/java/org/aspectj/ajde/ui/BuildConfigModel.java
  3. 1
    2
      ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
  4. 5
    9
      org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java
  5. 4
    4
      org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java
  6. 6
    16
      org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java
  7. 1
    2
      org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java
  8. 1
    2
      org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java
  9. 1
    2
      runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java
  10. 4
    4
      taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java
  11. 1
    2
      taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java
  12. 1
    2
      weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java
  13. 1
    2
      weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java
  14. 2
    3
      weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java
  15. 1
    2
      weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java
  16. 1
    2
      weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java
  17. 1
    2
      weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java

+ 2
- 2
ajde/src/main/java/org/aspectj/ajde/internal/LstBuildConfigManager.java View File

} }


private void notifyConfigChanged() { private void notifyConfigChanged() {
for (Object element : listeners) {
((BuildConfigListener) element).currConfigChanged(currConfigFilePath);
for (BuildConfigListener element : listeners) {
element.currConfigChanged(currConfigFilePath);
} }
} }



+ 2
- 2
ajde/src/main/java/org/aspectj/ajde/ui/BuildConfigModel.java View File

} }


if (node != null && node.getChildren() != null) { 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) if (foundNode != null)
return foundNode; return foundNode;
} }

+ 1
- 2
ajde/src/main/java/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java View File

} }
} }
if (node.getChildren() != null) { if (node.getChildren() != null) {
for (Object element : node.getChildren()) {
IProgramElement IProgramElement = (IProgramElement)element;
for (IProgramElement IProgramElement : node.getChildren()) {
if (acceptNode(IProgramElement, properties)) { if (acceptNode(IProgramElement, properties)) {
children.add(createViewNode(IProgramElement, properties)); children.add(createViewNode(IProgramElement, properties));
} }

+ 5
- 9
org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/core/builder/EmacsStructureModelManager.java View File



private void printDecls(IProgramElement node) { private void printDecls(IProgramElement node) {
print("("); print("(");
for (Object nodeObject : node.getChildren()) {
for (IProgramElement child : node.getChildren()) {
// this ignores relations on the compile unit // this ignores relations on the compile unit
// throw new RuntimeException("unimplemented"); // throw new RuntimeException("unimplemented");
// if (nodeObject instanceof IProgramElement) { // if (nodeObject instanceof IProgramElement) {
IProgramElement child = (IProgramElement) nodeObject;
printDecl(child, true); printDecl(child, true);
// } // }
// else if (nodeObject instanceof LinkNode) { // else if (nodeObject instanceof LinkNode) {
if (it3.hasNext()) { if (it3.hasNext()) {
while (it3.hasNext()) { while (it3.hasNext()) {
// this ignores relations on the compile unit // 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);
} }
} }
} }

+ 4
- 4
org.aspectj.ajdt.core/src/main/java/org/aspectj/org/eclipse/jdt/core/dom/AjASTConverter.java View File

} else if (declare instanceof DeclareParents) { } else if (declare instanceof DeclareParents) {
DeclareParents dp = (DeclareParents) declare; DeclareParents dp = (DeclareParents) declare;
declareDeclaration = new org.aspectj.org.eclipse.jdt.core.dom.DeclareParentsDeclaration(this.ast, dp.isExtends()); 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) { if (pNode instanceof AbstractTypePattern) {
((DeclareParentsDeclaration) declareDeclaration) ((DeclareParentsDeclaration) declareDeclaration)
.setChildTypePattern((AbstractTypePattern) pNode);
.setChildTypePattern(pNode);
} }
TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns(); TypePattern[] weaverTypePatterns = dp.getParents().getTypePatterns();
List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns(); List typePatterns = ((DeclareParentsDeclaration) declareDeclaration).parentTypePatterns();
declareDeclaration = new DeclareSoftDeclaration(this.ast); declareDeclaration = new DeclareSoftDeclaration(this.ast);
DeclareSoft ds = (DeclareSoft) declare; DeclareSoft ds = (DeclareSoft) declare;
((DeclareSoftDeclaration) declareDeclaration).setPointcut(convert(ds.getPointcut())); ((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) { if (pNode instanceof AbstractTypePattern) {
((DeclareSoftDeclaration) declareDeclaration) ((DeclareSoftDeclaration) declareDeclaration)
.setTypePattern((AbstractTypePattern) pNode);
.setTypePattern(pNode);
} }
} }



+ 6
- 16
org.aspectj.matcher/src/main/java/org/aspectj/weaver/CrosscuttingMembers.java View File

Set<Object> theseTypeMungers = new HashSet<>(); Set<Object> theseTypeMungers = new HashSet<>();
Set<Object> otherTypeMungers = new HashSet<>(); Set<Object> otherTypeMungers = new HashSet<>();
if (!careAboutShadowMungers) { 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 { } else {

+ 1
- 2
org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/AnnotationPointcut.java View File

if (kind == Shadow.FieldGet || kind == Shadow.FieldSet) { if (kind == Shadow.FieldGet || kind == Shadow.FieldSet) {
// FIXME asc should include supers with getInterTypeMungersIncludingSupers ? // FIXME asc should include supers with getInterTypeMungersIncludingSupers ?
List<ConcreteTypeMunger> mungers = rMember.getDeclaringType().resolve(shadow.getIWorld()).getInterTypeMungers(); 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) { if (typeMunger.getMunger() instanceof NewFieldTypeMunger) {
ResolvedMember fakerm = typeMunger.getSignature(); ResolvedMember fakerm = typeMunger.getSignature();
if (fakerm.equals(member)) { if (fakerm.equals(member)) {

+ 1
- 2
org.aspectj.matcher/src/main/java/org/aspectj/weaver/tools/StandardPointcutParser.java View File

*/ */
private StandardPointcutParser(Set<PointcutPrimitive> supportedPointcutKinds, World world) { private StandardPointcutParser(Set<PointcutPrimitive> supportedPointcutKinds, World world) {
supportedPrimitives = supportedPointcutKinds; supportedPrimitives = supportedPointcutKinds;
for (Object supportedPointcutKind : supportedPointcutKinds) {
PointcutPrimitive element = (PointcutPrimitive) supportedPointcutKind;
for (PointcutPrimitive element : supportedPointcutKinds) {
if ((element == PointcutPrimitive.IF) || (element == PointcutPrimitive.CFLOW) if ((element == PointcutPrimitive.IF) || (element == PointcutPrimitive.CFLOW)
|| (element == PointcutPrimitive.CFLOW_BELOW)) { || (element == PointcutPrimitive.CFLOW_BELOW)) {
throw new UnsupportedOperationException("Cannot handle if, cflow, and cflowbelow primitives"); throw new UnsupportedOperationException("Cannot handle if, cflow, and cflowbelow primitives");

+ 1
- 2
runtime/src/main/java/org/aspectj/runtime/internal/cflowstack/ThreadCounterImpl11.java View File

Thread t = (Thread)e.nextElement(); Thread t = (Thread)e.nextElement();
if (!t.isAlive()) dead_stacks.add(t); 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); counters.remove(t);
} }
change_count = 0; change_count = 0;

+ 4
- 4
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/Ajc2.java View File

List<File> newIncludes = new ArrayList<>(); List<File> newIncludes = new ArrayList<>();
List<String> newArguments = new ArrayList<>(); List<String> newArguments = new ArrayList<>();
if (argfiles != null) { if (argfiles != null) {
for (Object o : argfiles) {
File argfile = ((Argfile) o).getFile();
for (Argfile o : argfiles) {
File argfile = o.getFile();
expandArgfile(argfile, newIncludes, newArguments); expandArgfile(argfile, newIncludes, newArguments);
} }
} }
} }


// Add the new included files // 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 // This is the same behavior found in Javac

+ 1
- 2
taskdefs/src/main/java/org/aspectj/tools/ant/taskdefs/AjcTask.java View File

} }
} }
if (0 < adapterFiles.size()) { if (0 < adapterFiles.size()) {
for (Object adapterFile : adapterFiles) {
File file = (File) adapterFile;
for (File file : adapterFiles) {
if (file.canRead() && FileUtil.hasSourceSuffix(file)) { if (file.canRead() && FileUtil.hasSourceSuffix(file)) {
list.add(file.getAbsolutePath()); list.add(file.getAbsolutePath());
} }

+ 1
- 2
weaver/src/main/java/org/aspectj/weaver/bcel/BcelShadow.java View File

if (foundMember == null) { if (foundMember == null) {
// check the ITD'd dooberries // check the ITD'd dooberries
List<ConcreteTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers(); List<ConcreteTypeMunger> mungers = relevantType.resolve(world).getInterTypeMungers();
for (Object munger : mungers) {
ConcreteTypeMunger typeMunger = (ConcreteTypeMunger) munger;
for (ConcreteTypeMunger typeMunger : mungers) {
if (typeMunger.getMunger() instanceof NewMethodTypeMunger if (typeMunger.getMunger() instanceof NewMethodTypeMunger
|| typeMunger.getMunger() instanceof NewConstructorTypeMunger) { || typeMunger.getMunger() instanceof NewConstructorTypeMunger) {
ResolvedMember fakerm = typeMunger.getSignature(); ResolvedMember fakerm = typeMunger.getSignature();

+ 1
- 2
weaver/src/main/java/org/aspectj/weaver/bcel/BcelWeaver.java View File

List<ShadowMunger> l = world.getCrosscuttingMembersSet().getShadowMungers(); List<ShadowMunger> l = world.getCrosscuttingMembersSet().getShadowMungers();
Set<AdviceLocation> alreadyWarnedLocations = new HashSet<>(); 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: // This will stop us incorrectly reporting deow checkers:
if (element instanceof BcelAdvice) { if (element instanceof BcelAdvice) {
BcelAdvice ba = (BcelAdvice) element; BcelAdvice ba = (BcelAdvice) element;

+ 2
- 3
weaver/src/main/java/org/aspectj/weaver/bcel/LazyClassGen.java View File

} }


void addInlinedSourceFileInfo(String fullpath, int highestLineNumber) { 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) { if (info.highestLineNumber < highestLineNumber) {
info.highestLineNumber = highestLineNumber; info.highestLineNumber = highestLineNumber;
} }

+ 1
- 2
weaver/src/main/java/org/aspectj/weaver/loadtime/definition/SimpleAOPParser.java View File

throws Exception { throws Exception {
sap.startElement(xml.getName(), xml.getAttributes()); sap.startElement(xml.getName(), xml.getAttributes());
Iterable<LightXMLParser> childrens = xml.getChildrens(); Iterable<LightXMLParser> childrens = xml.getChildrens();
for (Object children : childrens) {
LightXMLParser child = (LightXMLParser) children;
for (LightXMLParser child : childrens) {
traverse(sap, child); traverse(sap, child);
} }
sap.endElement(xml.getName()); sap.endElement(xml.getName());

+ 1
- 2
weaver/src/main/java/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java View File

parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader()); parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader());
} }
Set<PointcutDesignatorHandler> additionalPointcutHandlers = world.getRegisteredPointcutHandlers(); Set<PointcutDesignatorHandler> additionalPointcutHandlers = world.getRegisteredPointcutHandlers();
for (Object additionalPointcutHandler : additionalPointcutHandlers) {
PointcutDesignatorHandler handler = (PointcutDesignatorHandler) additionalPointcutHandler;
for (PointcutDesignatorHandler handler : additionalPointcutHandlers) {
parser.registerPointcutDesignatorHandler(handler); parser.registerPointcutDesignatorHandler(handler);
} }



+ 1
- 2
weaver/src/main/java/org/aspectj/weaver/tools/WeavingAdaptor.java View File



private void registerAspectLibraries(List<String> aspectPath) { private void registerAspectLibraries(List<String> aspectPath) {
// System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")"); // System.err.println("? WeavingAdaptor.registerAspectLibraries(" + aspectPath + ")");
for (Object o : aspectPath) {
String libName = (String) o;
for (String libName : aspectPath) {
addAspectLibrary(libName); addAspectLibrary(libName);
} }



Loading…
Cancel
Save