diff --git a/tools/layoutlib/.idea/compiler.xml b/tools/layoutlib/.idea/compiler.xml
index 5aaaf18f9d94e..35961a2896ac5 100644
--- a/tools/layoutlib/.idea/compiler.xml
+++ b/tools/layoutlib/.idea/compiler.xml
@@ -21,7 +21,5 @@
-
-
-
+
\ No newline at end of file
diff --git a/tools/layoutlib/create/Android.mk b/tools/layoutlib/create/Android.mk
index e6f0bc306b072..c7f2c41376874 100644
--- a/tools/layoutlib/create/Android.mk
+++ b/tools/layoutlib/create/Android.mk
@@ -20,7 +20,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_JAR_MANIFEST := manifest.txt
LOCAL_STATIC_JAVA_LIBRARIES := \
- asm-4.0
+ asm-5.0
LOCAL_MODULE := layoutlib_create
diff --git a/tools/layoutlib/create/create.iml b/tools/layoutlib/create/create.iml
index 9b18e73aae90d..b2b14b4e8a917 100644
--- a/tools/layoutlib/create/create.iml
+++ b/tools/layoutlib/create/create.iml
@@ -1,6 +1,6 @@
-
+
@@ -9,12 +9,12 @@
-
+
-
+
-
+
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
index a6902a40b1a31..758bd48e60670 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AbstractClassAdapter.java
@@ -21,7 +21,6 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
@@ -44,7 +43,7 @@ public abstract class AbstractClassAdapter extends ClassVisitor {
abstract String renameInternalType(String name);
public AbstractClassAdapter(ClassVisitor cv) {
- super(Opcodes.ASM4, cv);
+ super(Main.ASM_VERSION, cv);
}
/**
@@ -239,7 +238,7 @@ public abstract class AbstractClassAdapter extends ClassVisitor {
* The names must be full qualified internal ASM names (e.g. com/blah/MyClass$InnerClass).
*/
public RenameMethodAdapter(MethodVisitor mv) {
- super(Opcodes.ASM4, mv);
+ super(Main.ASM_VERSION, mv);
}
@Override
@@ -276,7 +275,8 @@ public abstract class AbstractClassAdapter extends ClassVisitor {
}
@Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+ public void visitMethodInsn(int opcode, String owner, String name, String desc,
+ boolean itf) {
// The owner sometimes turns out to be a type descriptor. We try to detect it and fix.
if (owner.indexOf(';') > 0) {
owner = renameTypeDesc(owner);
@@ -285,7 +285,7 @@ public abstract class AbstractClassAdapter extends ClassVisitor {
}
desc = renameMethodDesc(desc);
- super.visitMethodInsn(opcode, owner, name, desc);
+ super.visitMethodInsn(opcode, owner, name, desc, itf);
}
@Override
@@ -330,7 +330,7 @@ public abstract class AbstractClassAdapter extends ClassVisitor {
private final SignatureVisitor mSv;
public RenameSignatureAdapter(SignatureVisitor sv) {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
mSv = sv;
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
index c8b2b8448e217..48544cac16ab9 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmAnalyzer.java
@@ -23,7 +23,6 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
@@ -65,7 +64,7 @@ public class AsmAnalyzer {
/** Glob patterns of files to keep as is. */
private final String[] mIncludeFileGlobs;
/** Internal names of classes that contain method calls that need to be rewritten. */
- private final Set mReplaceMethodCallClasses = new HashSet();
+ private final Set mReplaceMethodCallClasses = new HashSet<>();
/**
* Creates a new analyzer.
@@ -97,8 +96,8 @@ public class AsmAnalyzer {
*/
public void analyze() throws IOException, LogAbortException {
- TreeMap zipClasses = new TreeMap();
- Map filesFound = new TreeMap();
+ TreeMap zipClasses = new TreeMap<>();
+ Map filesFound = new TreeMap<>();
parseZip(mOsSourceJar, zipClasses, filesFound);
mLog.info("Found %d classes in input JAR%s.", zipClasses.size(),
@@ -189,7 +188,7 @@ public class AsmAnalyzer {
*/
Map findIncludes(Map zipClasses)
throws LogAbortException {
- TreeMap found = new TreeMap();
+ TreeMap found = new TreeMap<>();
mLog.debug("Find classes to include.");
@@ -318,10 +317,10 @@ public class AsmAnalyzer {
Map findDeps(Map zipClasses,
Map inOutKeepClasses) {
- TreeMap deps = new TreeMap();
- TreeMap new_deps = new TreeMap();
- TreeMap new_keep = new TreeMap();
- TreeMap temp = new TreeMap();
+ TreeMap deps = new TreeMap<>();
+ TreeMap new_deps = new TreeMap<>();
+ TreeMap new_keep = new TreeMap<>();
+ TreeMap temp = new TreeMap<>();
DependencyVisitor visitor = getVisitor(zipClasses,
inOutKeepClasses, new_keep,
@@ -399,7 +398,7 @@ public class AsmAnalyzer {
Map outKeep,
Map inDeps,
Map outDeps) {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
mZipClasses = zipClasses;
mInKeep = inKeep;
mOutKeep = outKeep;
@@ -557,7 +556,7 @@ public class AsmAnalyzer {
private class MyFieldVisitor extends FieldVisitor {
public MyFieldVisitor() {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
}
@Override
@@ -630,7 +629,7 @@ public class AsmAnalyzer {
private String mOwnerClass;
public MyMethodVisitor(String ownerClass) {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
mOwnerClass = ownerClass;
}
@@ -719,7 +718,8 @@ public class AsmAnalyzer {
// instruction that invokes a method
@Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+ public void visitMethodInsn(int opcode, String owner, String name, String desc,
+ boolean itf) {
// owner is the internal name of the method's owner class
considerName(owner);
@@ -779,7 +779,7 @@ public class AsmAnalyzer {
private class MySignatureVisitor extends SignatureVisitor {
public MySignatureVisitor() {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
}
// ---------------------------------------------------
@@ -878,7 +878,7 @@ public class AsmAnalyzer {
private class MyAnnotationVisitor extends AnnotationVisitor {
public MyAnnotationVisitor() {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
}
// Visits a primitive value of an annotation
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
index 8f0ad01c6dc3a..5b99a6bae195a 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/AsmGenerator.java
@@ -91,7 +91,7 @@ public class AsmGenerator {
mLog = log;
mOsDestJar = osDestJar;
ArrayList> injectedClasses =
- new ArrayList>(Arrays.asList(createInfo.getInjectedClasses()));
+ new ArrayList<>(Arrays.asList(createInfo.getInjectedClasses()));
// Search for and add anonymous inner classes also.
ListIterator> iter = injectedClasses.listIterator();
while (iter.hasNext()) {
@@ -107,25 +107,25 @@ public class AsmGenerator {
}
}
mInjectClasses = injectedClasses.toArray(new Class>[0]);
- mStubMethods = new HashSet(Arrays.asList(createInfo.getOverriddenMethods()));
+ mStubMethods = new HashSet<>(Arrays.asList(createInfo.getOverriddenMethods()));
// Create the map/set of methods to change to delegates
- mDelegateMethods = new HashMap>();
+ mDelegateMethods = new HashMap<>();
addToMap(createInfo.getDelegateMethods(), mDelegateMethods);
for (String className : createInfo.getDelegateClassNatives()) {
className = binaryToInternalClassName(className);
Set methods = mDelegateMethods.get(className);
if (methods == null) {
- methods = new HashSet();
+ methods = new HashSet<>();
mDelegateMethods.put(className, methods);
}
methods.add(DelegateClassAdapter.ALL_NATIVES);
}
// Create the map of classes to rename.
- mRenameClasses = new HashMap();
- mClassesNotRenamed = new HashSet();
+ mRenameClasses = new HashMap<>();
+ mClassesNotRenamed = new HashSet<>();
String[] renameClasses = createInfo.getRenamedClasses();
int n = renameClasses.length;
for (int i = 0; i < n; i += 2) {
@@ -138,7 +138,7 @@ public class AsmGenerator {
}
// Create a map of classes to be refactored.
- mRefactorClasses = new HashMap();
+ mRefactorClasses = new HashMap<>();
String[] refactorClasses = createInfo.getJavaPkgClasses();
n = refactorClasses.length;
for (int i = 0; i < n; i += 2) {
@@ -149,7 +149,7 @@ public class AsmGenerator {
}
// create the map of renamed class -> return type of method to delete.
- mDeleteReturns = new HashMap>();
+ mDeleteReturns = new HashMap<>();
String[] deleteReturns = createInfo.getDeleteReturns();
Set returnTypes = null;
String renamedClass = null;
@@ -172,12 +172,12 @@ public class AsmGenerator {
// just a standard return type, we add it to the list.
if (returnTypes == null) {
- returnTypes = new HashSet();
+ returnTypes = new HashSet<>();
}
returnTypes.add(binaryToInternalClassName(className));
}
- mPromotedFields = new HashMap>();
+ mPromotedFields = new HashMap<>();
addToMap(createInfo.getPromotedFields(), mPromotedFields);
mInjectedMethodsMap = createInfo.getInjectedMethodsMap();
@@ -197,7 +197,7 @@ public class AsmGenerator {
String methodOrFieldName = entry.substring(pos + 1);
Set set = map.get(className);
if (set == null) {
- set = new HashSet();
+ set = new HashSet<>();
map.put(className, set);
}
set.add(methodOrFieldName);
@@ -247,7 +247,7 @@ public class AsmGenerator {
/** Generates the final JAR */
public void generate() throws IOException {
- TreeMap all = new TreeMap();
+ TreeMap all = new TreeMap<>();
for (Class> clazz : mInjectClasses) {
String name = classToEntryPath(clazz);
@@ -314,7 +314,7 @@ public class AsmGenerator {
* e.g. for the input "android.view.View" it returns "android/view/View.class"
*/
String classNameToEntryPath(String className) {
- return className.replaceAll("\\.", "/").concat(".class");
+ return className.replace('.', '/').concat(".class");
}
/**
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
index 2c955fd9d9bb2..4748a7c7b2f1a 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/ClassHasNativeVisitor.java
@@ -31,7 +31,7 @@ import org.objectweb.asm.Opcodes;
*/
public class ClassHasNativeVisitor extends ClassVisitor {
public ClassHasNativeVisitor() {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
}
private boolean mHasNativeMethods = false;
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 7c838e97cd635..c063b529cb7d4 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -111,7 +111,7 @@ public final class CreateInfo implements ICreateInfo {
public Set getExcludedClasses() {
String[] refactoredClasses = getJavaPkgClasses();
int count = refactoredClasses.length / 2 + EXCLUDED_CLASSES.length;
- Set excludedClasses = new HashSet(count);
+ Set excludedClasses = new HashSet<>(count);
for (int i = 0; i < refactoredClasses.length; i+=2) {
excludedClasses.add(refactoredClasses[i]);
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
index ae4a57d8eea4e..cb3de4e6efac1 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateClassAdapter.java
@@ -58,7 +58,7 @@ public class DelegateClassAdapter extends ClassVisitor {
ClassVisitor cv,
String className,
Set delegateMethods) {
- super(Opcodes.ASM4, cv);
+ super(Main.ASM_VERSION, cv);
mLog = log;
mClassName = className;
mDelegateMethods = delegateMethods;
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter.java
index 12690db547a98..a1b1d944cf6d6 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DelegateMethodAdapter.java
@@ -121,7 +121,7 @@ class DelegateMethodAdapter extends MethodVisitor {
String methodName,
String desc,
boolean isStatic) {
- super(Opcodes.ASM4);
+ super(Main.ASM_VERSION);
mLog = log;
mOrgWriter = mvOriginal;
mDelWriter = mvDelegate;
@@ -184,7 +184,7 @@ class DelegateMethodAdapter extends MethodVisitor {
mDelWriter.visitLineNumber((Integer) p[0], (Label) p[1]);
}
- ArrayList paramTypes = new ArrayList();
+ ArrayList paramTypes = new ArrayList<>();
String delegateClassName = mClassName + DELEGATE_SUFFIX;
boolean pushedArg0 = false;
int maxStack = 0;
@@ -249,7 +249,8 @@ class DelegateMethodAdapter extends MethodVisitor {
mDelWriter.visitMethodInsn(Opcodes.INVOKESTATIC,
delegateClassName,
mMethodName,
- desc);
+ desc,
+ false);
Type returnType = Type.getReturnType(mDesc);
mDelWriter.visitInsn(returnType.getOpcode(Opcodes.IRETURN));
@@ -367,9 +368,9 @@ class DelegateMethodAdapter extends MethodVisitor {
}
@Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+ public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
if (mOrgWriter != null) {
- mOrgWriter.visitMethodInsn(opcode, owner, name, desc);
+ mOrgWriter.visitMethodInsn(opcode, owner, name, desc, itf);
}
}
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
index 61b64a2e8e38c..aa68ea0998447 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/DependencyFinder.java
@@ -26,7 +26,6 @@ import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import org.objectweb.asm.signature.SignatureReader;
import org.objectweb.asm.signature.SignatureVisitor;
@@ -82,7 +81,7 @@ public class DependencyFinder {
Map> missing = findMissingClasses(deps, zipClasses.keySet());
- List