Permalink
Browse files

fix removing of standard enum methods

  • Loading branch information...
1 parent 549a187 commit e430d9df0628e761a288970cf00d370de3b7852b @mebigfatguy mebigfatguy committed Jan 28, 2011
Showing with 10 additions and 4 deletions.
  1. +10 −4 src/com/mebigfatguy/deadmethods/FindDeadMethods.java
@@ -174,16 +174,22 @@ private void removeSyntheticMethods(ClassRepository repo, Set<String> methods)
private void removeStandardEnumMethods(ClassRepository repo, Set<String> methods) throws IOException {
ClassInfo info = repo.getClassInfo("java/lang/Enum");
- for (MethodInfo methodInfo : info.getMethodInfo()) {
- clearDerivedMethods(methods, info, methodInfo.toString());
- }
+ {
+ MethodInfo methodInfo = new MethodInfo("valueOf", "(Ljava/lang/String;)?", Opcodes.ACC_PUBLIC);
+ clearDerivedMethods(methods, info, methodInfo.toString());
+ }
+ {
+ MethodInfo methodInfo = new MethodInfo("values", "()[?", Opcodes.ACC_PUBLIC);
+ clearDerivedMethods(methods, info, methodInfo.toString());
+ }
+
}
private void clearDerivedMethods(Set<String> methods, ClassInfo info, String methodInfo) throws IOException {
Set<ClassInfo> derivedInfos = info.getDerivedClasses();
for (ClassInfo derivedInfo : derivedInfos) {
- methods.remove(derivedInfo.getClassName() + ":" + methodInfo);
+ methods.remove(derivedInfo.getClassName() + ":" + methodInfo.replaceAll("\\?", "L" + derivedInfo.getClassName() + ";"));
clearDerivedMethods(methods, derivedInfo, methodInfo);
}
}

0 comments on commit e430d9d

Please sign in to comment.