diff options
Diffstat (limited to 'src/proguard/optimize/peephole/ClassMerger.java')
-rw-r--r-- | src/proguard/optimize/peephole/ClassMerger.java | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/src/proguard/optimize/peephole/ClassMerger.java b/src/proguard/optimize/peephole/ClassMerger.java index 4971cab..1e1a950 100644 --- a/src/proguard/optimize/peephole/ClassMerger.java +++ b/src/proguard/optimize/peephole/ClassMerger.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2011 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2009 Eric Lafortune (eric@graphics.cornell.edu) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -21,7 +21,6 @@ package proguard.optimize.peephole; import proguard.classfile.*; -import proguard.classfile.constant.ClassConstant; import proguard.classfile.constant.visitor.*; import proguard.classfile.editor.*; import proguard.classfile.util.*; @@ -60,8 +59,6 @@ implements ClassVisitor, private final boolean mergeInterfacesAggressively; private final ClassVisitor extraClassVisitor; - private final MemberVisitor fieldOptimizationInfoCopier = new FieldOptimizationInfoCopier(); - /** * Creates a new ClassMerger that will merge classes into the given target @@ -154,7 +151,7 @@ implements ClassVisitor, // infinite recursion. (programClass.getAccessFlags() & ClassConstants.INTERNAL_ACC_ANNOTATTION) == 0 && - // Only merge classes if we can change the access permissions, or + // Only merge classes if we can change the access permissioms, or // if they are in the same package, or // if they are public and don't contain or invoke package visible // class members. @@ -238,12 +235,11 @@ implements ClassVisitor, targetClass.u2accessFlags = ((targetAccessFlags & sourceAccessFlags) & - (ClassConstants.INTERNAL_ACC_INTERFACE | + (ClassConstants.INTERNAL_ACC_INTERFACE | ClassConstants.INTERNAL_ACC_ABSTRACT)) | ((targetAccessFlags | sourceAccessFlags) & - (ClassConstants.INTERNAL_ACC_PUBLIC | - ClassConstants.INTERNAL_ACC_SUPER | + (ClassConstants.INTERNAL_ACC_PUBLIC | ClassConstants.INTERNAL_ACC_ANNOTATTION | ClassConstants.INTERNAL_ACC_ENUM)); @@ -264,7 +260,7 @@ implements ClassVisitor, // Copy over the class members. MemberAdder memberAdder = - new MemberAdder(targetClass, fieldOptimizationInfoCopier); + new MemberAdder(targetClass); programClass.fieldsAccept(memberAdder); programClass.methodsAccept(memberAdder); @@ -340,8 +336,10 @@ implements ClassVisitor, // Visit all superclasses and interfaces, collecting the ones that have // static initializers. clazz.hierarchyAccept(true, true, true, false, - new StaticInitializerContainingClassFilter( - new ClassCollector(set))); + new NamedMethodVisitor(ClassConstants.INTERNAL_METHOD_NAME_CLINIT, + ClassConstants.INTERNAL_METHOD_TYPE_INIT, + new MemberToClassVisitor( + new ClassCollector(set)))); return set; } @@ -370,19 +368,12 @@ implements ClassVisitor, */ private Set caughtSuperClasses(Clazz clazz) { - // Don't bother if this isn't an exception at all. - if (!clazz.extends_(ClassConstants.INTERNAL_NAME_JAVA_LANG_THROWABLE)) - { - return Collections.EMPTY_SET; - } - - // Visit all superclasses, collecting the ones that are caught - // (plus java.lang.Object, in the current implementation). Set set = new HashSet(); + // Visit all superclasses, collecting the ones that are caught. clazz.hierarchyAccept(true, true, false, false, new CaughtClassFilter( - new ClassCollector(set))); + new ClassCollector(set))); return set; } @@ -547,30 +538,4 @@ implements ClassVisitor, targetClass = clazz; } } - - - /** - * This MemberVisitor copies field optimization info from copied fields. - */ - private static class FieldOptimizationInfoCopier - extends SimplifiedVisitor - implements MemberVisitor - { - public void visitProgramField(ProgramClass programClass, ProgramField programField) - { - // Copy the optimization info from the field that was just copied. - ProgramField copiedField = (ProgramField)programField.getVisitorInfo(); - Object info = copiedField.getVisitorInfo(); - - programField.setVisitorInfo(info instanceof FieldOptimizationInfo ? - new FieldOptimizationInfo((FieldOptimizationInfo)info) : - info); - } - - - public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod) - { - // Linked methods share their optimization info. - } - } }
\ No newline at end of file |