summaryrefslogtreecommitdiffstats
path: root/src/proguard/classfile/util/ClassReferenceInitializer.java
diff options
context:
space:
mode:
authorYing Wang <wangying@google.com>2012-02-27 18:34:24 -0800
committerYing Wang <wangying@google.com>2012-02-27 18:34:24 -0800
commit9f606f95f03a75961498803e24bee6799a7c0885 (patch)
treea45f4d74feda9b76277a0c9ced55ad15d82248a1 /src/proguard/classfile/util/ClassReferenceInitializer.java
parentcfead78069f3dc32998dc118ee08cab3867acea2 (diff)
downloadexternal_proguard-9f606f95f03a75961498803e24bee6799a7c0885.tar.gz
external_proguard-9f606f95f03a75961498803e24bee6799a7c0885.tar.bz2
external_proguard-9f606f95f03a75961498803e24bee6799a7c0885.zip
This reverts commit cfead78069f3dc32998dc118ee08cab3867acea2. Bug: 6079915
Diffstat (limited to 'src/proguard/classfile/util/ClassReferenceInitializer.java')
-rw-r--r--src/proguard/classfile/util/ClassReferenceInitializer.java108
1 files changed, 47 insertions, 61 deletions
diff --git a/src/proguard/classfile/util/ClassReferenceInitializer.java b/src/proguard/classfile/util/ClassReferenceInitializer.java
index e7709ab..b1f2c27 100644
--- a/src/proguard/classfile/util/ClassReferenceInitializer.java
+++ b/src/proguard/classfile/util/ClassReferenceInitializer.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
@@ -166,30 +166,17 @@ implements ClassVisitor,
}
- public void visitMethodHandleConstant(Clazz clazz, MethodHandleConstant methodHandleConstant)
- {
- // Fill out the MethodHandle class.
- methodHandleConstant.javaLangInvokeMethodHandleClass =
- findClass(clazz.getName(), ClassConstants.INTERNAL_NAME_JAVA_LANG_INVOKE_METHOD_HANDLE);
- }
-
-
public void visitAnyRefConstant(Clazz clazz, RefConstant refConstant)
{
String className = refConstant.getClassName(clazz);
- // Methods for array types should be found in the Object class.
- if (ClassUtil.isInternalArrayType(className))
- {
- className = ClassConstants.INTERNAL_NAME_JAVA_LANG_OBJECT;
- }
-
// See if we can find the referenced class.
// Unresolved references are assumed to refer to library classes
// that will not change anyway.
Clazz referencedClass = findClass(clazz.getName(), className);
- if (referencedClass != null)
+ if (referencedClass != null &&
+ !ClassUtil.isInternalArrayType(className))
{
String name = refConstant.getName(clazz);
String type = refConstant.getType(clazz);
@@ -207,7 +194,7 @@ implements ClassVisitor,
if (refConstant.referencedMember == null)
{
- // We haven't found the class member anywhere in the hierarchy.
+ // We've haven't found the class member anywhere in the hierarchy.
missingMemberWarningPrinter.print(clazz.getName(),
className,
"Warning: " +
@@ -229,7 +216,7 @@ implements ClassVisitor,
// Fill out the referenced class.
classConstant.referencedClass =
- findClass(className, ClassUtil.internalClassNameFromClassType(classConstant.getName(clazz)));
+ findClass(className, classConstant.getName(clazz));
// Fill out the Class class.
classConstant.javaLangClassClass =
@@ -237,14 +224,6 @@ implements ClassVisitor,
}
- public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
- {
- // Fill out the MethodType class.
- methodTypeConstant.javaLangInvokeMethodTypeClass =
- findClass(clazz.getName(), ClassConstants.INTERNAL_NAME_JAVA_LANG_INVOKE_METHOD_TYPE);
- }
-
-
// Implementations for AttributeVisitor.
public void visitAnyAttribute(Clazz clazz, Attribute attribute) {}
@@ -256,36 +235,49 @@ implements ClassVisitor,
String enclosingClassName = enclosingMethodAttribute.getClassName(clazz);
// See if we can find the referenced class.
- enclosingMethodAttribute.referencedClass =
- findClass(className, enclosingClassName);
+ Clazz referencedClass = findClass(className, enclosingClassName);
- if (enclosingMethodAttribute.referencedClass != null)
+ if (referencedClass == null)
{
- // Is there an enclosing method? Otherwise it's just initialization
- // code outside of the constructors.
- if (enclosingMethodAttribute.u2nameAndTypeIndex != 0)
- {
- String name = enclosingMethodAttribute.getName(clazz);
- String type = enclosingMethodAttribute.getType(clazz);
+ // We couldn't find the enclosing class.
+ missingClassWarningPrinter.print(className,
+ enclosingClassName,
+ "Warning: " +
+ ClassUtil.externalClassName(className) +
+ ": can't find enclosing class " +
+ ClassUtil.externalClassName(enclosingClassName));
+ return;
+ }
- // See if we can find the method in the referenced class.
- enclosingMethodAttribute.referencedMethod =
- enclosingMethodAttribute.referencedClass.findMethod(name, type);
+ // Make sure there is actually an enclosed method.
+ if (enclosingMethodAttribute.u2nameAndTypeIndex == 0)
+ {
+ return;
+ }
- if (enclosingMethodAttribute.referencedMethod == null)
- {
- // We couldn't find the enclosing method.
- missingMemberWarningPrinter.print(className,
- enclosingClassName,
- "Warning: " +
- ClassUtil.externalClassName(className) +
- ": can't find enclosing method '" +
- ClassUtil.externalFullMethodDescription(enclosingClassName, 0, name, type) +
- "' in class " +
- ClassUtil.externalClassName(enclosingClassName));
- }
- }
+ String name = enclosingMethodAttribute.getName(clazz);
+ String type = enclosingMethodAttribute.getType(clazz);
+
+ // See if we can find the method in the referenced class.
+ Method referencedMethod = referencedClass.findMethod(name, type);
+
+ if (referencedMethod == null)
+ {
+ // We couldn't find the enclosing method.
+ missingMemberWarningPrinter.print(className,
+ enclosingClassName,
+ "Warning: " +
+ ClassUtil.externalClassName(className) +
+ ": can't find enclosing method '" +
+ ClassUtil.externalFullMethodDescription(enclosingClassName, 0, name, type) +
+ "' in class " +
+ ClassUtil.externalClassName(enclosingClassName));
+ return;
}
+
+ // Save the references.
+ enclosingMethodAttribute.referencedClass = referencedClass;
+ enclosingMethodAttribute.referencedMethod = referencedMethod;
}
@@ -509,17 +501,11 @@ implements ClassVisitor,
*/
private Clazz findClass(String referencingClassName, String name)
{
- // Is it an array type?
- if (ClassUtil.isInternalArrayType(name))
+ // Ignore any primitive array types.
+ if (ClassUtil.isInternalArrayType(name) &&
+ !ClassUtil.isInternalClassType(name))
{
- // Ignore any primitive array types.
- if (!ClassUtil.isInternalClassType(name))
- {
- return null;
- }
-
- // Strip the array part.
- name = ClassUtil.internalClassNameFromClassType(name);
+ return null;
}
// First look for the class in the program class pool.