aboutsummaryrefslogtreecommitdiffstats
path: root/src/proguard/optimize/info
diff options
context:
space:
mode:
Diffstat (limited to 'src/proguard/optimize/info')
-rw-r--r--src/proguard/optimize/info/AccessMethodMarker.java19
-rw-r--r--src/proguard/optimize/info/BackwardBranchMarker.java2
-rw-r--r--src/proguard/optimize/info/CatchExceptionMarker.java2
-rw-r--r--src/proguard/optimize/info/CaughtClassFilter.java2
-rw-r--r--src/proguard/optimize/info/CaughtClassMarker.java7
-rw-r--r--src/proguard/optimize/info/ClassOptimizationInfo.java16
-rw-r--r--src/proguard/optimize/info/ClassOptimizationInfoSetter.java2
-rw-r--r--src/proguard/optimize/info/DotClassFilter.java2
-rw-r--r--src/proguard/optimize/info/DotClassMarker.java2
-rw-r--r--src/proguard/optimize/info/ExceptionInstructionChecker.java104
-rw-r--r--src/proguard/optimize/info/FieldOptimizationInfo.java56
-rw-r--r--src/proguard/optimize/info/InstanceofClassFilter.java2
-rw-r--r--src/proguard/optimize/info/InstanceofClassMarker.java2
-rw-r--r--src/proguard/optimize/info/InstantiationClassFilter.java2
-rw-r--r--src/proguard/optimize/info/InstantiationClassMarker.java2
-rw-r--r--src/proguard/optimize/info/MemberOptimizationInfoSetter.java18
-rw-r--r--src/proguard/optimize/info/MethodInvocationMarker.java2
-rw-r--r--src/proguard/optimize/info/MethodOptimizationInfo.java6
-rw-r--r--src/proguard/optimize/info/NoSideEffectMethodMarker.java2
-rw-r--r--src/proguard/optimize/info/NonPrivateMemberMarker.java16
-rw-r--r--src/proguard/optimize/info/PackageVisibleMemberContainingClassMarker.java28
-rw-r--r--src/proguard/optimize/info/PackageVisibleMemberInvokingClassMarker.java72
-rw-r--r--src/proguard/optimize/info/ParameterUsageMarker.java8
-rw-r--r--src/proguard/optimize/info/ReadWriteFieldMarker.java2
-rw-r--r--src/proguard/optimize/info/SideEffectInstructionChecker.java109
-rw-r--r--src/proguard/optimize/info/SideEffectMethodMarker.java2
-rw-r--r--src/proguard/optimize/info/StaticInitializerContainingClassFilter.java62
-rw-r--r--src/proguard/optimize/info/StaticInitializerContainingClassMarker.java65
-rw-r--r--src/proguard/optimize/info/SuperInvocationMarker.java2
-rw-r--r--src/proguard/optimize/info/VariableUsageMarker.java11
30 files changed, 170 insertions, 457 deletions
diff --git a/src/proguard/optimize/info/AccessMethodMarker.java b/src/proguard/optimize/info/AccessMethodMarker.java
index 8d758ce..6965cec 100644
--- a/src/proguard/optimize/info/AccessMethodMarker.java
+++ b/src/proguard/optimize/info/AccessMethodMarker.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,8 +21,7 @@
package proguard.optimize.info;
import proguard.classfile.*;
-import proguard.classfile.attribute.*;
-import proguard.classfile.attribute.visitor.*;
+import proguard.classfile.attribute.CodeAttribute;
import proguard.classfile.constant.*;
import proguard.classfile.constant.visitor.ConstantVisitor;
import proguard.classfile.instruction.*;
@@ -72,20 +71,6 @@ implements InstructionVisitor,
}
- public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- {
- // Check the bootstrap method.
- invokeDynamicConstant.bootstrapMethodHandleAccept(clazz, this);
- }
-
-
- public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
- {
- // Check the method reference.
- clazz.constantPoolEntryAccept(methodHandleConstant.u2referenceIndex, this);
- }
-
-
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
// Check the referenced class.
diff --git a/src/proguard/optimize/info/BackwardBranchMarker.java b/src/proguard/optimize/info/BackwardBranchMarker.java
index d53a5b2..9e09b0f 100644
--- a/src/proguard/optimize/info/BackwardBranchMarker.java
+++ b/src/proguard/optimize/info/BackwardBranchMarker.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
diff --git a/src/proguard/optimize/info/CatchExceptionMarker.java b/src/proguard/optimize/info/CatchExceptionMarker.java
index 5d74047..3f2a06f 100644
--- a/src/proguard/optimize/info/CatchExceptionMarker.java
+++ b/src/proguard/optimize/info/CatchExceptionMarker.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
diff --git a/src/proguard/optimize/info/CaughtClassFilter.java b/src/proguard/optimize/info/CaughtClassFilter.java
index 4f7caff..5e17763 100644
--- a/src/proguard/optimize/info/CaughtClassFilter.java
+++ b/src/proguard/optimize/info/CaughtClassFilter.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
diff --git a/src/proguard/optimize/info/CaughtClassMarker.java b/src/proguard/optimize/info/CaughtClassMarker.java
index 5a60aaf..0cc350e 100644
--- a/src/proguard/optimize/info/CaughtClassMarker.java
+++ b/src/proguard/optimize/info/CaughtClassMarker.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
@@ -25,9 +25,8 @@ import proguard.classfile.util.SimplifiedVisitor;
import proguard.classfile.visitor.ClassVisitor;
/**
- * This ClassVisitor marks all program classes that it visits as caught.
- * This means that these classes are exception classes that occur in exception
- * handlers.
+ * This InstructionVisitor marks all classes that are used in an 'instanceof'
+ * test by any of the instructions that it visits.
*
* @author Eric Lafortune
*/
diff --git a/src/proguard/optimize/info/ClassOptimizationInfo.java b/src/proguard/optimize/info/ClassOptimizationInfo.java
index e440eef..99b6e7b 100644
--- a/src/proguard/optimize/info/ClassOptimizationInfo.java
+++ b/src/proguard/optimize/info/ClassOptimizationInfo.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
@@ -34,7 +34,6 @@ public class ClassOptimizationInfo
private boolean isInstanceofed = false;
private boolean isDotClassed = false;
private boolean isCaught = false;
- private boolean containsStaticInitializer = false;
private boolean containsPackageVisibleMembers = false;
private boolean invokesPackageVisibleMembers = false;
private Clazz targetClass;
@@ -88,18 +87,6 @@ public class ClassOptimizationInfo
}
- public void setContainsStaticInitializer()
- {
- containsStaticInitializer = true;
- }
-
-
- public boolean containsStaticInitializer()
- {
- return containsStaticInitializer;
- }
-
-
public void setContainsPackageVisibleMembers()
{
containsPackageVisibleMembers = true;
@@ -142,7 +129,6 @@ public class ClassOptimizationInfo
this.isInstanceofed |= other.isInstanceofed;
this.isDotClassed |= other.isDotClassed;
this.isCaught |= other.isCaught;
- this.containsStaticInitializer |= other.containsStaticInitializer;
this.containsPackageVisibleMembers |= other.containsPackageVisibleMembers;
this.invokesPackageVisibleMembers |= other.invokesPackageVisibleMembers;
}
diff --git a/src/proguard/optimize/info/ClassOptimizationInfoSetter.java b/src/proguard/optimize/info/ClassOptimizationInfoSetter.java
index bc58f2d..9cb167c 100644
--- a/src/proguard/optimize/info/ClassOptimizationInfoSetter.java
+++ b/src/proguard/optimize/info/ClassOptimizationInfoSetter.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
diff --git a/src/proguard/optimize/info/DotClassFilter.java b/src/proguard/optimize/info/DotClassFilter.java
index c55925c..8cbe7f0 100644
--- a/src/proguard/optimize/info/DotClassFilter.java
+++ b/src/proguard/optimize/info/DotClassFilter.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
diff --git a/src/proguard/optimize/info/DotClassMarker.java b/src/proguard/optimize/info/DotClassMarker.java
index 2819441..b5f12a7 100644
--- a/src/proguard/optimize/info/DotClassMarker.java
+++ b/src/proguard/optimize/info/DotClassMarker.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
diff --git a/src/proguard/optimize/info/ExceptionInstructionChecker.java b/src/proguard/optimize/info/ExceptionInstructionChecker.java
index 40287f3..2792d90 100644
--- a/src/proguard/optimize/info/ExceptionInstructionChecker.java
+++ b/src/proguard/optimize/info/ExceptionInstructionChecker.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
@@ -67,39 +67,34 @@ implements InstructionVisitor
byte opcode = simpleInstruction.opcode;
// Check for instructions that may throw exceptions.
- // Note that monitorexit can not sensibly throw exceptions, except the
- // broken and deprecated asynchronous ThreadDeath. Removing the
- // artificial infinite looping exception blocks that recent compilers
- // add does not strictly follow the JVM specs, but it does have the
- // additional benefit of avoiding a bug in the JVM in JDK 1.1.
- switch (opcode)
+ if (opcode == InstructionConstants.OP_IDIV ||
+ opcode == InstructionConstants.OP_LDIV ||
+ opcode == InstructionConstants.OP_IREM ||
+ opcode == InstructionConstants.OP_LREM ||
+ opcode == InstructionConstants.OP_IALOAD ||
+ opcode == InstructionConstants.OP_LALOAD ||
+ opcode == InstructionConstants.OP_FALOAD ||
+ opcode == InstructionConstants.OP_DALOAD ||
+ opcode == InstructionConstants.OP_AALOAD ||
+ opcode == InstructionConstants.OP_BALOAD ||
+ opcode == InstructionConstants.OP_CALOAD ||
+ opcode == InstructionConstants.OP_SALOAD ||
+ opcode == InstructionConstants.OP_IASTORE ||
+ opcode == InstructionConstants.OP_LASTORE ||
+ opcode == InstructionConstants.OP_FASTORE ||
+ opcode == InstructionConstants.OP_DASTORE ||
+ opcode == InstructionConstants.OP_AASTORE ||
+ opcode == InstructionConstants.OP_BASTORE ||
+ opcode == InstructionConstants.OP_CASTORE ||
+ opcode == InstructionConstants.OP_SASTORE ||
+ opcode == InstructionConstants.OP_NEWARRAY ||
+ opcode == InstructionConstants.OP_ARRAYLENGTH ||
+ opcode == InstructionConstants.OP_ATHROW ||
+ opcode == InstructionConstants.OP_MONITORENTER ||
+ opcode == InstructionConstants.OP_MONITOREXIT)
{
- case InstructionConstants.OP_IDIV:
- case InstructionConstants.OP_LDIV:
- case InstructionConstants.OP_IREM:
- case InstructionConstants.OP_LREM:
- case InstructionConstants.OP_IALOAD:
- case InstructionConstants.OP_LALOAD:
- case InstructionConstants.OP_FALOAD:
- case InstructionConstants.OP_DALOAD:
- case InstructionConstants.OP_AALOAD:
- case InstructionConstants.OP_BALOAD:
- case InstructionConstants.OP_CALOAD:
- case InstructionConstants.OP_SALOAD:
- case InstructionConstants.OP_IASTORE:
- case InstructionConstants.OP_LASTORE:
- case InstructionConstants.OP_FASTORE:
- case InstructionConstants.OP_DASTORE:
- case InstructionConstants.OP_AASTORE:
- case InstructionConstants.OP_BASTORE:
- case InstructionConstants.OP_CASTORE:
- case InstructionConstants.OP_SASTORE:
- case InstructionConstants.OP_NEWARRAY:
- case InstructionConstants.OP_ARRAYLENGTH:
- case InstructionConstants.OP_ATHROW:
- case InstructionConstants.OP_MONITORENTER:
- // These instructions may throw exceptions.
- mayThrowExceptions = true;
+ // These instructions may throw exceptions.
+ mayThrowExceptions = true;
}
}
@@ -110,32 +105,31 @@ implements InstructionVisitor
byte opcode = constantInstruction.opcode;
// Check for instructions that may throw exceptions.
- switch (opcode)
+ if (opcode == InstructionConstants.OP_GETSTATIC ||
+ opcode == InstructionConstants.OP_PUTSTATIC ||
+ opcode == InstructionConstants.OP_GETFIELD ||
+ opcode == InstructionConstants.OP_PUTFIELD ||
+ opcode == InstructionConstants.OP_INVOKEVIRTUAL ||
+ opcode == InstructionConstants.OP_INVOKESPECIAL ||
+ opcode == InstructionConstants.OP_INVOKESTATIC ||
+ opcode == InstructionConstants.OP_INVOKEINTERFACE ||
+ opcode == InstructionConstants.OP_NEW ||
+ opcode == InstructionConstants.OP_ANEWARRAY ||
+ opcode == InstructionConstants.OP_CHECKCAST ||
+ opcode == InstructionConstants.OP_MULTIANEWARRAY)
{
- case InstructionConstants.OP_GETSTATIC:
- case InstructionConstants.OP_PUTSTATIC:
- case InstructionConstants.OP_GETFIELD:
- case InstructionConstants.OP_PUTFIELD:
- case InstructionConstants.OP_INVOKEVIRTUAL:
- case InstructionConstants.OP_INVOKESPECIAL:
- case InstructionConstants.OP_INVOKESTATIC:
- case InstructionConstants.OP_INVOKEINTERFACE:
- case InstructionConstants.OP_INVOKEDYNAMIC:
- case InstructionConstants.OP_NEW:
- case InstructionConstants.OP_ANEWARRAY:
- case InstructionConstants.OP_CHECKCAST:
- case InstructionConstants.OP_INSTANCEOF:
- case InstructionConstants.OP_MULTIANEWARRAY:
- // These instructions may throw exceptions.
- mayThrowExceptions = true;
+ // These instructions may throw exceptions.
+ mayThrowExceptions = true;
}
-
-// case InstructionConstants.OP_INVOKEVIRTUAL:
-// case InstructionConstants.OP_INVOKESPECIAL:
-// case InstructionConstants.OP_INVOKESTATIC:
-// case InstructionConstants.OP_INVOKEINTERFACE:
+// else
+// if (opcode == InstructionConstants.OP_INVOKEVIRTUAL ||
+// opcode == InstructionConstants.OP_INVOKESPECIAL ||
+// opcode == InstructionConstants.OP_INVOKESTATIC ||
+// opcode == InstructionConstants.OP_INVOKEINTERFACE)
+// {
// // Check if the invoking the method may throw an exception.
// clazz.constantPoolEntryAccept(constantInstruction.constantIndex, this);
+// }
}
diff --git a/src/proguard/optimize/info/FieldOptimizationInfo.java b/src/proguard/optimize/info/FieldOptimizationInfo.java
index 6797a14..7a2d068 100644
--- a/src/proguard/optimize/info/FieldOptimizationInfo.java
+++ b/src/proguard/optimize/info/FieldOptimizationInfo.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,11 +21,8 @@
package proguard.optimize.info;
import proguard.classfile.*;
-import proguard.classfile.attribute.visitor.*;
-import proguard.classfile.attribute.*;
-import proguard.classfile.util.*;
+import proguard.classfile.util.MethodLinker;
import proguard.evaluation.value.*;
-import proguard.evaluation.ConstantValueFactory;
/**
* This class stores some optimization information that can be attached to
@@ -34,11 +31,8 @@ import proguard.evaluation.ConstantValueFactory;
* @author Eric Lafortune
*/
public class FieldOptimizationInfo
-extends SimplifiedVisitor
-implements AttributeVisitor
{
- private static final SpecificValueFactory VALUE_FACTORY = new SpecificValueFactory();
- private static final ConstantValueFactory CONSTANT_VALUE_FACTORY = new ConstantValueFactory(VALUE_FACTORY);
+ private static final SpecificValueFactory VALUE_FACTORY = new SpecificValueFactory();
private boolean isWritten;
private boolean isRead;
@@ -49,33 +43,9 @@ implements AttributeVisitor
public FieldOptimizationInfo(Clazz clazz, Field field)
{
- int accessFlags = field.getAccessFlags();
-
isWritten =
- isRead = (accessFlags & ClassConstants.INTERNAL_ACC_VOLATILE) != 0;
-
- if ((accessFlags & ClassConstants.INTERNAL_ACC_STATIC) != 0)
- {
- // See if we can initialize the static field with a constant value.
- field.accept(clazz, new AllAttributeVisitor(this));
- }
-
- if ((accessFlags & ClassConstants.INTERNAL_ACC_FINAL) == 0 &&
- value == null)
- {
- // Otherwise initialize the non-final field with the default value.
- value = initialValue(field.getDescriptor(clazz));
- }
- }
-
-
- public FieldOptimizationInfo(FieldOptimizationInfo FieldOptimizationInfo)
- {
- this.isWritten = FieldOptimizationInfo.isWritten;
- this.isRead = FieldOptimizationInfo.isRead;
- this.canBeMadePrivate = FieldOptimizationInfo.canBeMadePrivate;
- this.referencedClass = FieldOptimizationInfo.referencedClass;
- this.value = FieldOptimizationInfo.value;
+ isRead = (field.getAccessFlags() & ClassConstants.INTERNAL_ACC_VOLATILE) != 0;
+ value = initialValue(field.getDescriptor(clazz));
}
@@ -143,18 +113,6 @@ implements AttributeVisitor
}
- // Implementations for AttributeVisitor.
-
- public void visitAnyAttribute(Clazz clazz, Attribute attribute) {}
-
-
- public void visitConstantValueAttribute(Clazz clazz, Field field, ConstantValueAttribute constantValueAttribute)
- {
- // Retrieve the initial static field value.
- value = CONSTANT_VALUE_FACTORY.constantValue(clazz, constantValueAttribute.u2constantValueIndex);
- }
-
-
// Small utility methods.
private Value initialValue(String type)
@@ -189,13 +147,13 @@ implements AttributeVisitor
public static void setFieldOptimizationInfo(Clazz clazz, Field field)
{
- field.setVisitorInfo(new FieldOptimizationInfo(clazz, field));
+ MethodLinker.lastMember(field).setVisitorInfo(new FieldOptimizationInfo(clazz, field));
}
public static FieldOptimizationInfo getFieldOptimizationInfo(Field field)
{
- Object visitorInfo = field.getVisitorInfo();
+ Object visitorInfo = MethodLinker.lastMember(field).getVisitorInfo();
return visitorInfo instanceof FieldOptimizationInfo ?
(FieldOptimizationInfo)visitorInfo :
diff --git a/src/proguard/optimize/info/InstanceofClassFilter.java b/src/proguard/optimize/info/InstanceofClassFilter.java
index 955fe9e..35e1d77 100644
--- a/src/proguard/optimize/info/InstanceofClassFilter.java
+++ b/src/proguard/optimize/info/InstanceofClassFilter.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
diff --git a/src/proguard/optimize/info/InstanceofClassMarker.java b/src/proguard/optimize/info/InstanceofClassMarker.java
index 6d2f8aa..c60e1f8 100644
--- a/src/proguard/optimize/info/InstanceofClassMarker.java
+++ b/src/proguard/optimize/info/InstanceofClassMarker.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
diff --git a/src/proguard/optimize/info/InstantiationClassFilter.java b/src/proguard/optimize/info/InstantiationClassFilter.java
index e67e0b5..a24e617 100644
--- a/src/proguard/optimize/info/InstantiationClassFilter.java
+++ b/src/proguard/optimize/info/InstantiationClassFilter.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
diff --git a/src/proguard/optimize/info/InstantiationClassMarker.java b/src/proguard/optimize/info/InstantiationClassMarker.java
index dc623c2..124c23b 100644
--- a/src/proguard/optimize/info/InstantiationClassMarker.java
+++ b/src/proguard/optimize/info/InstantiationClassMarker.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
diff --git a/src/proguard/optimize/info/MemberOptimizationInfoSetter.java b/src/proguard/optimize/info/MemberOptimizationInfoSetter.java
index d222d81..a170a8e 100644
--- a/src/proguard/optimize/info/MemberOptimizationInfoSetter.java
+++ b/src/proguard/optimize/info/MemberOptimizationInfoSetter.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
@@ -38,22 +38,22 @@ implements MemberVisitor
{
// Implementations for MemberVisitor.
- public void visitProgramField(ProgramClass programClass, ProgramField programField)
+ public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
- if (!KeepMarker.isKept(programField))
+ if (!KeepMarker.isKept(programMethod))
{
- FieldOptimizationInfo.setFieldOptimizationInfo(programClass,
- programField);
+ MethodOptimizationInfo.setMethodOptimizationInfo(programClass,
+ programMethod);
}
}
- public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
+ public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
- if (!KeepMarker.isKept(programMethod))
+ if (!KeepMarker.isKept(programField))
{
- MethodOptimizationInfo.setMethodOptimizationInfo(programClass,
- programMethod);
+ FieldOptimizationInfo.setFieldOptimizationInfo(programClass,
+ programField);
}
}
}
diff --git a/src/proguard/optimize/info/MethodInvocationMarker.java b/src/proguard/optimize/info/MethodInvocationMarker.java
index 9d573b7..2528c94 100644
--- a/src/proguard/optimize/info/MethodInvocationMarker.java
+++ b/src/proguard/optimize/info/MethodInvocationMarker.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
diff --git a/src/proguard/optimize/info/MethodOptimizationInfo.java b/src/proguard/optimize/info/MethodOptimizationInfo.java
index dd76f97..d3b1bde 100644
--- a/src/proguard/optimize/info/MethodOptimizationInfo.java
+++ b/src/proguard/optimize/info/MethodOptimizationInfo.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
@@ -204,7 +204,7 @@ public class MethodOptimizationInfo
public void setParameterUsed(int parameterIndex)
{
- usedParameters |= 1L << parameterIndex;
+ usedParameters |= 1 << parameterIndex;
}
@@ -216,7 +216,7 @@ public class MethodOptimizationInfo
public boolean isParameterUsed(int parameterIndex)
{
- return parameterIndex >= 64 || (usedParameters & (1L << parameterIndex)) != 0;
+ return parameterIndex >= 64 || (usedParameters & (1 << parameterIndex)) != 0;
}
diff --git a/src/proguard/optimize/info/NoSideEffectMethodMarker.java b/src/proguard/optimize/info/NoSideEffectMethodMarker.java
index 2e0516b..5c78408 100644
--- a/src/proguard/optimize/info/NoSideEffectMethodMarker.java
+++ b/src/proguard/optimize/info/NoSideEffectMethodMarker.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
diff --git a/src/proguard/optimize/info/NonPrivateMemberMarker.java b/src/proguard/optimize/info/NonPrivateMemberMarker.java
index 23e33a9..d451643 100644
--- a/src/proguard/optimize/info/NonPrivateMemberMarker.java
+++ b/src/proguard/optimize/info/NonPrivateMemberMarker.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
@@ -77,9 +77,15 @@ implements ClassVisitor,
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
{
- // The referenced class member, if any, can never be made private,
- // even if it's in the same class.
- stringConstant.referencedMemberAccept(this);
+ Clazz referencedClass = stringConstant.referencedClass;
+
+ // Is it refering to another class or class member?
+ if (referencedClass != null &&
+ !referencedClass.equals(clazz))
+ {
+ // The referenced class member, if any, can never be made private.
+ stringConstant.referencedMemberAccept(this);
+ }
}
@@ -87,7 +93,7 @@ implements ClassVisitor,
{
Clazz referencedClass = refConstant.referencedClass;
- // Is it referring to a class member in another class?
+ // Is it refering to a class member in another class?
// The class member might be in another class, or
// it may be referenced through another class.
if (referencedClass != null &&
diff --git a/src/proguard/optimize/info/PackageVisibleMemberContainingClassMarker.java b/src/proguard/optimize/info/PackageVisibleMemberContainingClassMarker.java
index 85ff4b9..d40bc6b 100644
--- a/src/proguard/optimize/info/PackageVisibleMemberContainingClassMarker.java
+++ b/src/proguard/optimize/info/PackageVisibleMemberContainingClassMarker.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
@@ -22,36 +22,18 @@ package proguard.optimize.info;
import proguard.classfile.*;
import proguard.classfile.util.SimplifiedVisitor;
-import proguard.classfile.visitor.*;
+import proguard.classfile.visitor.MemberVisitor;
/**
- * This ClassVisitor marks all classes that contain package visible members.
+ * This MemberVisitor marks all classes that contain visited package visible
+ * members.
*
* @author Eric Lafortune
*/
public class PackageVisibleMemberContainingClassMarker
extends SimplifiedVisitor
-implements ClassVisitor,
- MemberVisitor
+implements MemberVisitor
{
- // Implementations for ClassVisitor.
-
- public void visitAnyClass(Clazz clazz)
- {
- // Check the class itself.
- if ((clazz.getAccessFlags() & ClassConstants.INTERNAL_ACC_PUBLIC) == 0)
- {
- setPackageVisibleMembers(clazz);
- }
- else
- {
- // Check the members.
- clazz.fieldsAccept(this);
- clazz.methodsAccept(this);
- }
- }
-
-
// Implementations for MemberVisitor.
public void visitAnyMember(Clazz clazz, Member member)
diff --git a/src/proguard/optimize/info/PackageVisibleMemberInvokingClassMarker.java b/src/proguard/optimize/info/PackageVisibleMemberInvokingClassMarker.java
index 42cc14f..9ec8ec6 100644
--- a/src/proguard/optimize/info/PackageVisibleMemberInvokingClassMarker.java
+++ b/src/proguard/optimize/info/PackageVisibleMemberInvokingClassMarker.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
@@ -24,87 +24,39 @@ import proguard.classfile.*;
import proguard.classfile.constant.visitor.ConstantVisitor;
import proguard.classfile.constant.*;
import proguard.classfile.util.SimplifiedVisitor;
-import proguard.classfile.visitor.*;
/**
- * This ConstantVisitor marks all classes that refer to package visible classes
- * or class members.
+ * This ConstantVisitor marks all classes that invoke package visible members
+ * in other classes.
*
* @author Eric Lafortune
*/
public class PackageVisibleMemberInvokingClassMarker
extends SimplifiedVisitor
-implements ConstantVisitor,
- ClassVisitor,
- MemberVisitor
+implements ConstantVisitor
{
- private Clazz referencingClass;
-
-
// Implementations for ConstantVisitor.
public void visitAnyConstant(Clazz clazz, Constant constant) {}
- public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
- {
- // Check the referenced class and class member, if any.
- if (stringConstant.referencedClass != clazz)
- {
- referencingClass = clazz;
-
- stringConstant.referencedClassAccept(this);
- stringConstant.referencedMemberAccept(this);
- }
- }
-
-
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
- // Check the referenced class and class member.
- if (refConstant.referencedClass != clazz)
- {
- referencingClass = clazz;
-
- refConstant.referencedClassAccept(this);
- refConstant.referencedMemberAccept(this);
- }
- }
-
-
- public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
- {
- // Check the referenced class.
- if (classConstant.referencedClass != clazz)
- {
- referencingClass = clazz;
-
- classConstant.referencedClassAccept(this);
- }
- }
-
-
- // Implementations for ClassVisitor.
-
- public void visitAnyClass(Clazz clazz)
- {
- if ((clazz.getAccessFlags() &
+ Clazz referencedClass = refConstant.referencedClass;
+ if (referencedClass != null &&
+ (referencedClass.getAccessFlags() &
ClassConstants.INTERNAL_ACC_PUBLIC) == 0)
{
- setInvokesPackageVisibleMembers(referencingClass);
+ setInvokesPackageVisibleMembers(clazz);
}
- }
-
- // Implementations for MemberVisitor.
-
- public void visitAnyMember(Clazz clazz, Member member)
- {
- if ((member.getAccessFlags() &
+ Member referencedMember = refConstant.referencedMember;
+ if (referencedMember != null &&
+ (referencedMember.getAccessFlags() &
(ClassConstants.INTERNAL_ACC_PUBLIC |
ClassConstants.INTERNAL_ACC_PRIVATE)) == 0)
{
- setInvokesPackageVisibleMembers(referencingClass);
+ setInvokesPackageVisibleMembers(clazz);
}
}
diff --git a/src/proguard/optimize/info/ParameterUsageMarker.java b/src/proguard/optimize/info/ParameterUsageMarker.java
index abae946..15ce88a 100644
--- a/src/proguard/optimize/info/ParameterUsageMarker.java
+++ b/src/proguard/optimize/info/ParameterUsageMarker.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,14 +21,14 @@
package proguard.optimize.info;
import proguard.classfile.*;
-import proguard.classfile.attribute.*;
-import proguard.classfile.attribute.visitor.AttributeVisitor;
import proguard.classfile.instruction.*;
import proguard.classfile.instruction.visitor.InstructionVisitor;
+import proguard.classfile.attribute.visitor.AttributeVisitor;
+import proguard.classfile.attribute.*;
import proguard.classfile.util.*;
import proguard.classfile.visitor.MemberVisitor;
-import proguard.evaluation.value.Value;
import proguard.optimize.evaluation.PartialEvaluator;
+import proguard.evaluation.value.*;
/**
* This MemberVisitor counts the parameters and marks the used parameters
diff --git a/src/proguard/optimize/info/ReadWriteFieldMarker.java b/src/proguard/optimize/info/ReadWriteFieldMarker.java
index 236cb17..57d8561 100644
--- a/src/proguard/optimize/info/ReadWriteFieldMarker.java
+++ b/src/proguard/optimize/info/ReadWriteFieldMarker.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
diff --git a/src/proguard/optimize/info/SideEffectInstructionChecker.java b/src/proguard/optimize/info/SideEffectInstructionChecker.java
index 1444e5a..8be9dc1 100644
--- a/src/proguard/optimize/info/SideEffectInstructionChecker.java
+++ b/src/proguard/optimize/info/SideEffectInstructionChecker.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
@@ -29,14 +29,11 @@ import proguard.classfile.instruction.visitor.InstructionVisitor;
import proguard.classfile.util.SimplifiedVisitor;
import proguard.classfile.visitor.*;
-import java.util.*;
-
/**
* This class can tell whether an instruction has any side effects. Return
* instructions can be included or not.
*
* @see ReadWriteFieldMarker
- * @see StaticInitializerContainingClassMarker
* @see NoSideEffectMethodMarker
* @see SideEffectMethodMarker
* @author Eric Lafortune
@@ -50,7 +47,6 @@ implements InstructionVisitor,
private final boolean includeReturnInstructions;
// A return value for the visitor methods.
- private Clazz referencingClass;
private boolean hasSideEffects;
@@ -64,7 +60,7 @@ implements InstructionVisitor,
{
hasSideEffects = false;
- instruction.accept(clazz, method, codeAttribute, offset, this);
+ instruction.accept(clazz, method, codeAttribute, offset, this);
return hasSideEffects;
}
@@ -122,16 +118,14 @@ implements InstructionVisitor,
public void visitConstantInstruction(Clazz clazz, Method method, CodeAttribute codeAttribute, int offset, ConstantInstruction constantInstruction)
{
byte opcode = constantInstruction.opcode;
+
// Check for instructions that might cause side effects.
- if (opcode == InstructionConstants.OP_GETSTATIC ||
- opcode == InstructionConstants.OP_PUTSTATIC ||
- opcode == InstructionConstants.OP_GETFIELD ||
- opcode == InstructionConstants.OP_PUTFIELD ||
- opcode == InstructionConstants.OP_INVOKEVIRTUAL ||
- opcode == InstructionConstants.OP_INVOKESPECIAL ||
- opcode == InstructionConstants.OP_INVOKESTATIC ||
- opcode == InstructionConstants.OP_INVOKEINTERFACE ||
- opcode == InstructionConstants.OP_INVOKEDYNAMIC)
+ if (opcode == InstructionConstants.OP_PUTSTATIC ||
+ opcode == InstructionConstants.OP_PUTFIELD ||
+ opcode == InstructionConstants.OP_INVOKEVIRTUAL ||
+ opcode == InstructionConstants.OP_INVOKESPECIAL ||
+ opcode == InstructionConstants.OP_INVOKESTATIC ||
+ opcode == InstructionConstants.OP_INVOKEINTERFACE)
{
// Check if the field is write-only or volatile, or if the invoked
// method is causing any side effects.
@@ -156,36 +150,48 @@ implements InstructionVisitor,
// Implementations for ConstantVisitor.
- public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- {
- // We'll have to assume invoking an unknown method has side effects.
- hasSideEffects = true;
- }
-
-
public void visitFieldrefConstant(Clazz clazz, FieldrefConstant fieldrefConstant)
{
- // Pass the referencing class.
- referencingClass = clazz;
-
// We'll have to assume accessing an unknown field has side effects.
hasSideEffects = true;
- // Check the referenced field, if known.
+ // Check the referenced field.
fieldrefConstant.referencedMemberAccept(this);
}
public void visitAnyMethodrefConstant(Clazz clazz, RefConstant refConstant)
{
- // Pass the referencing class.
- referencingClass = clazz;
+ Member referencedMember = refConstant.referencedMember;
- // We'll have to assume invoking an unknown method has side effects.
- hasSideEffects = true;
-
- // Check the referenced method, if known.
- refConstant.referencedMemberAccept(this);
+ // Do we have a reference to the method?
+ if (referencedMember == null)
+ {
+ // We'll have to assume invoking the unknown method has side effects.
+ hasSideEffects = true;
+ }
+ else
+ {
+ // First check the referenced method itself.
+ refConstant.referencedMemberAccept(this);
+
+ // If the result isn't conclusive, check down the hierarchy.
+ if (!hasSideEffects)
+ {
+ Clazz referencedClass = refConstant.referencedClass;
+ Method referencedMethod = (Method)referencedMember;
+
+ // Check all other implementations of the method down the class
+ // hierarchy.
+ if ((referencedMethod.getAccessFlags() & ClassConstants.INTERNAL_ACC_PRIVATE) == 0)
+ {
+ clazz.hierarchyAccept(false, false, false, true,
+ new NamedMethodVisitor(referencedMethod.getName(referencedClass),
+ referencedMethod.getDescriptor(referencedClass),
+ this));
+ }
+ }
+ }
}
@@ -193,24 +199,14 @@ implements InstructionVisitor,
public void visitProgramField(ProgramClass programClass, ProgramField programField)
{
- hasSideEffects =
- (ReadWriteFieldMarker.isRead(programField) &&
- ReadWriteFieldMarker.isWritten(programField)) ||
- ((programField.getAccessFlags() & ClassConstants.INTERNAL_ACC_VOLATILE) != 0) ||
- (!programClass.equals(referencingClass) &&
- !initializedSuperClasses(referencingClass).containsAll(initializedSuperClasses(programClass)));
+ hasSideEffects = ReadWriteFieldMarker.isRead(programField);
}
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
{
- // Note that side effects already include synchronization of some
- // implementation of the method.
- hasSideEffects =
- !NoSideEffectMethodMarker.hasNoSideEffects(programMethod) &&
- (SideEffectMethodMarker.hasSideEffects(programMethod) ||
- (!programClass.equals(referencingClass) &&
- !initializedSuperClasses(referencingClass).containsAll(initializedSuperClasses(programClass))));
+ hasSideEffects = hasSideEffects ||
+ SideEffectMethodMarker.hasSideEffects(programMethod);
}
@@ -222,24 +218,7 @@ implements InstructionVisitor,
public void visitLibraryMethod(LibraryClass libraryClass, LibraryMethod libraryMethod)
{
- hasSideEffects =
- !NoSideEffectMethodMarker.hasNoSideEffects(libraryMethod);
- }
-
-
- /**
- * Returns the set of superclasses and interfaces that are initialized.
- */
- private Set initializedSuperClasses(Clazz clazz)
- {
- Set set = new HashSet();
-
- // Visit all superclasses and interfaces, collecting the ones that have
- // static initializers.
- clazz.hierarchyAccept(true, true, true, false,
- new StaticInitializerContainingClassFilter(
- new ClassCollector(set)));
-
- return set;
+ hasSideEffects = hasSideEffects ||
+ !NoSideEffectMethodMarker.hasNoSideEffects(libraryMethod);
}
}
diff --git a/src/proguard/optimize/info/SideEffectMethodMarker.java b/src/proguard/optimize/info/SideEffectMethodMarker.java
index d73179e..25fda72 100644
--- a/src/proguard/optimize/info/SideEffectMethodMarker.java
+++ b/src/proguard/optimize/info/SideEffectMethodMarker.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
diff --git a/src/proguard/optimize/info/StaticInitializerContainingClassFilter.java b/src/proguard/optimize/info/StaticInitializerContainingClassFilter.java
deleted file mode 100644
index 197668d..0000000
--- a/src/proguard/optimize/info/StaticInitializerContainingClassFilter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ProGuard -- shrinking, optimization, obfuscation, and preverification
- * of Java bytecode.
- *
- * Copyright (c) 2002-2011 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package proguard.optimize.info;
-
-import proguard.classfile.*;
-import proguard.classfile.visitor.ClassVisitor;
-
-/**
- * This ClassVisitor delegates all its method calls to another ClassVisitor,
- * but only for Clazz objects that are instantiated.
- *
- * @author Eric Lafortune
- */
-public class StaticInitializerContainingClassFilter
-implements ClassVisitor
-{
- private final ClassVisitor classVisitor;
-
-
- public StaticInitializerContainingClassFilter(ClassVisitor classVisitor)
- {
- this.classVisitor = classVisitor;
- }
-
-
- // Implementations for ClassVisitor.
-
- public void visitProgramClass(ProgramClass programClass)
- {
- if (StaticInitializerContainingClassMarker.containsStaticInitializer(programClass))
- {
- classVisitor.visitProgramClass(programClass);
- }
- }
-
-
- public void visitLibraryClass(LibraryClass libraryClass)
- {
- if (StaticInitializerContainingClassMarker.containsStaticInitializer(libraryClass))
- {
- classVisitor.visitLibraryClass(libraryClass);
- }
- }
-} \ No newline at end of file
diff --git a/src/proguard/optimize/info/StaticInitializerContainingClassMarker.java b/src/proguard/optimize/info/StaticInitializerContainingClassMarker.java
deleted file mode 100644
index a121250..0000000
--- a/src/proguard/optimize/info/StaticInitializerContainingClassMarker.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ProGuard -- shrinking, optimization, obfuscation, and preverification
- * of Java bytecode.
- *
- * Copyright (c) 2002-2011 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
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package proguard.optimize.info;
-
-import proguard.classfile.*;
-import proguard.classfile.util.SimplifiedVisitor;
-import proguard.classfile.visitor.*;
-
-/**
- * This ClassVisitor marks all classes that contain static initializers.
- *
- * @author Eric Lafortune
- */
-public class StaticInitializerContainingClassMarker
-extends SimplifiedVisitor
-implements ClassVisitor
-{
- // Implementations for ClassVisitor.
-
- public void visitAnyClass(Clazz clazz)
- {
- if (clazz.findMethod(ClassConstants.INTERNAL_METHOD_NAME_CLINIT,
- ClassConstants.INTERNAL_METHOD_TYPE_CLINIT) != null)
- {
- setStaticInitializer(clazz);
- }
- }
-
-
- // Small utility methods.
-
- private static void setStaticInitializer(Clazz clazz)
- {
- ClassOptimizationInfo info = ClassOptimizationInfo.getClassOptimizationInfo(clazz);
- if (info != null)
- {
- info.setContainsStaticInitializer();
- }
- }
-
-
- public static boolean containsStaticInitializer(Clazz clazz)
- {
- ClassOptimizationInfo info = ClassOptimizationInfo.getClassOptimizationInfo(clazz);
- return info == null || info.containsStaticInitializer();
- }
-} \ No newline at end of file
diff --git a/src/proguard/optimize/info/SuperInvocationMarker.java b/src/proguard/optimize/info/SuperInvocationMarker.java
index 07e33bb..6f3d3bd 100644
--- a/src/proguard/optimize/info/SuperInvocationMarker.java
+++ b/src/proguard/optimize/info/SuperInvocationMarker.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
diff --git a/src/proguard/optimize/info/VariableUsageMarker.java b/src/proguard/optimize/info/VariableUsageMarker.java
index a1c6a9a..660c4ba 100644
--- a/src/proguard/optimize/info/VariableUsageMarker.java
+++ b/src/proguard/optimize/info/VariableUsageMarker.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
@@ -27,8 +27,6 @@ import proguard.classfile.instruction.*;
import proguard.classfile.instruction.visitor.InstructionVisitor;
import proguard.classfile.util.SimplifiedVisitor;
-import java.util.Arrays;
-
/**
* This AttributeVisitor marks the local variables that are used in the code
* attributes that it visits.
@@ -64,13 +62,14 @@ implements AttributeVisitor,
// Try to reuse the previous array.
if (variableUsed.length < maxLocals)
{
- // Create a new array.
variableUsed = new boolean[maxLocals];
}
else
{
- // Reset the array.
- Arrays.fill(variableUsed, 0, maxLocals, false);
+ for (int index = 0; index < maxLocals; index++)
+ {
+ variableUsed[index] = false;
+ }
}
codeAttribute.instructionsAccept(clazz, method, this);