diff options
Diffstat (limited to 'src/proguard/preverify')
-rw-r--r-- | src/proguard/preverify/CodePreverifier.java | 8 | ||||
-rw-r--r-- | src/proguard/preverify/CodeSubroutineInliner.java | 27 | ||||
-rw-r--r-- | src/proguard/preverify/Preverifier.java | 23 | ||||
-rw-r--r-- | src/proguard/preverify/SubroutineInliner.java | 4 |
4 files changed, 35 insertions, 27 deletions
diff --git a/src/proguard/preverify/CodePreverifier.java b/src/proguard/preverify/CodePreverifier.java index 7c38259..60e7afe 100644 --- a/src/proguard/preverify/CodePreverifier.java +++ b/src/proguard/preverify/CodePreverifier.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 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 @@ -25,9 +25,9 @@ import proguard.classfile.attribute.*; import proguard.classfile.attribute.preverification.*; import proguard.classfile.attribute.visitor.AttributeVisitor; import proguard.classfile.editor.*; -import proguard.classfile.instruction.*; +import proguard.classfile.instruction.InstructionConstants; import proguard.classfile.util.SimplifiedVisitor; -import proguard.classfile.visitor.*; +import proguard.classfile.visitor.ClassPrinter; import proguard.evaluation.*; import proguard.evaluation.value.*; import proguard.optimize.evaluation.*; @@ -158,7 +158,7 @@ implements AttributeVisitor partialEvaluator.getVariablesBefore(0)); // Special case: the <init> method. - if (method.getName(programClass).equals(ClassConstants.INTERNAL_METHOD_NAME_INIT)) + if (method.getName(programClass).equals(ClassConstants.METHOD_NAME_INIT)) { initialVariables[0] = VerificationTypeFactory.createUninitializedThisType(); } diff --git a/src/proguard/preverify/CodeSubroutineInliner.java b/src/proguard/preverify/CodeSubroutineInliner.java index c1549a3..f0b5775 100644 --- a/src/proguard/preverify/CodeSubroutineInliner.java +++ b/src/proguard/preverify/CodeSubroutineInliner.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 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 @@ -48,9 +48,8 @@ implements AttributeVisitor, private static boolean DEBUG = System.getProperty("csi") != null; //*/ - private final BranchTargetFinder branchTargetFinder = new BranchTargetFinder(); - private final CodeAttributeComposer codeAttributeComposer = new CodeAttributeComposer(true, true); + private final CodeAttributeComposer codeAttributeComposer = new CodeAttributeComposer(true, true, true); private ExceptionInfoVisitor subroutineExceptionInliner = this; private int clipStart = 0; @@ -119,7 +118,7 @@ implements AttributeVisitor, Instruction instruction = InstructionFactory.create(codeAttribute.code, offset); int instructionLength = instruction.length(offset); - // Is this returning subroutine? + // Is this a returning subroutine? if (branchTargetFinder.isSubroutine(offset) && branchTargetFinder.isSubroutineReturning(offset)) { @@ -228,8 +227,22 @@ implements AttributeVisitor, public void visitAnyInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, Instruction instruction) { - // Append the instruction. - codeAttributeComposer.appendInstruction(offset, instruction); + if (branchTargetFinder.isSubroutineStart(offset)) + { + if (DEBUG) + { + System.out.println(" Replacing first subroutine instruction "+instruction.toString(offset)+" by a label"); + } + + // Append a label at this offset instead of saving the subroutine + // return address. + codeAttributeComposer.appendLabel(offset); + } + else + { + // Append the instruction. + codeAttributeComposer.appendInstruction(offset, instruction); + } } @@ -268,7 +281,7 @@ implements AttributeVisitor, { if (DEBUG) { - System.out.println(" Replacing first subroutine instruction at ["+offset+"] by a label"); + System.out.println(" Replacing first subroutine instruction "+variableInstruction.toString(offset)+" by a label"); } // Append a label at this offset instead of saving the subroutine diff --git a/src/proguard/preverify/Preverifier.java b/src/proguard/preverify/Preverifier.java index da9649b..59dad7f 100644 --- a/src/proguard/preverify/Preverifier.java +++ b/src/proguard/preverify/Preverifier.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 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 @@ -54,20 +54,15 @@ public class Preverifier programClassPool.classesAccept(new ClassCleaner()); // Preverify all methods. - ClassVisitor preverifier = + // Classes for JME must be preverified. + // Classes for JSE 6 may optionally be preverified. + // Classes for JSE 7 or higher must be preverified. + programClassPool.classesAccept( + new ClassVersionFilter(configuration.microEdition ? + ClassConstants.CLASS_VERSION_1_0 : + ClassConstants.CLASS_VERSION_1_6, new AllMethodVisitor( new AllAttributeVisitor( - new CodePreverifier(configuration.microEdition))); - - // Classes from Java 6 may optionally be preverified. - // Classes from Java 7 or higher must be preverified. - if (!configuration.microEdition) - { - preverifier = - new ClassVersionFilter(ClassConstants.INTERNAL_CLASS_VERSION_1_6, - preverifier); - } - - programClassPool.classesAccept(preverifier); + new CodePreverifier(configuration.microEdition))))); } } diff --git a/src/proguard/preverify/SubroutineInliner.java b/src/proguard/preverify/SubroutineInliner.java index e21c469..b069612 100644 --- a/src/proguard/preverify/SubroutineInliner.java +++ b/src/proguard/preverify/SubroutineInliner.java @@ -2,7 +2,7 @@ * ProGuard -- shrinking, optimization, obfuscation, and preverification * of Java bytecode. * - * Copyright (c) 2002-2013 Eric Lafortune (eric@graphics.cornell.edu) + * Copyright (c) 2002-2014 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 @@ -64,7 +64,7 @@ public class SubroutineInliner if (!configuration.microEdition) { inliner = - new ClassVersionFilter(ClassConstants.INTERNAL_CLASS_VERSION_1_6, + new ClassVersionFilter(ClassConstants.CLASS_VERSION_1_6, inliner); } |