From d3c63bf35a992b4ccc562c337a15889549a7ee68 Mon Sep 17 00:00:00 2001
From: Redkale <22250530@qq.com>
Date: Wed, 4 Apr 2018 14:03:55 +0800
Subject: [PATCH]
---
src/org/redkale/asm/AnnotationVisitor.java | 3 --
src/org/redkale/asm/ClassVisitor.java | 6 ---
src/org/redkale/asm/ClassWriter.java | 32 -------------
src/org/redkale/asm/FieldVisitor.java | 6 ---
src/org/redkale/asm/Handle.java | 28 -----------
src/org/redkale/asm/MethodVisitor.java | 54 ----------------------
src/org/redkale/asm/Opcodes.java | 6 ---
src/org/redkale/net/http/Rest.java | 4 +-
src/org/redkale/util/Creator.java | 4 +-
9 files changed, 4 insertions(+), 139 deletions(-)
diff --git a/src/org/redkale/asm/AnnotationVisitor.java b/src/org/redkale/asm/AnnotationVisitor.java
index 0b5157138..90f57e135 100644
--- a/src/org/redkale/asm/AnnotationVisitor.java
+++ b/src/org/redkale/asm/AnnotationVisitor.java
@@ -102,9 +102,6 @@ public abstract class AnnotationVisitor {
* method calls. May be null.
*/
public AnnotationVisitor(final int api, final AnnotationVisitor av) {
- if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
- throw new IllegalArgumentException();
- }
this.api = api;
this.av = av;
}
diff --git a/src/org/redkale/asm/ClassVisitor.java b/src/org/redkale/asm/ClassVisitor.java
index b9bd39fe6..5958e2b91 100644
--- a/src/org/redkale/asm/ClassVisitor.java
+++ b/src/org/redkale/asm/ClassVisitor.java
@@ -104,9 +104,6 @@ public abstract class ClassVisitor {
* calls. May be null.
*/
public ClassVisitor(final int api, final ClassVisitor cv) {
- if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
- throw new IllegalArgumentException();
- }
this.api = api;
this.cv = cv;
}
@@ -244,9 +241,6 @@ public abstract class ClassVisitor {
*/
public AnnotationVisitor visitTypeAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (cv != null) {
return cv.visitTypeAnnotation(typeRef, typePath, desc, visible);
}
diff --git a/src/org/redkale/asm/ClassWriter.java b/src/org/redkale/asm/ClassWriter.java
index 81f964eb5..9ab5ecc97 100644
--- a/src/org/redkale/asm/ClassWriter.java
+++ b/src/org/redkale/asm/ClassWriter.java
@@ -1297,38 +1297,6 @@ public class ClassWriter extends ClassVisitor {
return result;
}
- /**
- * Adds a handle to the constant pool of the class being build. Does nothing
- * if the constant pool already contains a similar item. This method is
- * intended for {@link Attribute} sub classes, and is normally not needed by
- * class generators or adapters.
- *
- * @param tag
- * the kind of this handle. Must be {@link Opcodes#H_GETFIELD},
- * {@link Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD},
- * {@link Opcodes#H_PUTSTATIC}, {@link Opcodes#H_INVOKEVIRTUAL},
- * {@link Opcodes#H_INVOKESTATIC},
- * {@link Opcodes#H_INVOKESPECIAL},
- * {@link Opcodes#H_NEWINVOKESPECIAL} or
- * {@link Opcodes#H_INVOKEINTERFACE}.
- * @param owner
- * the internal name of the field or method owner class.
- * @param name
- * the name of the field or method.
- * @param desc
- * the descriptor of the field or method.
- * @return the index of a new or already existing method type reference
- * item.
- *
- * @deprecated this method is superseded by
- * {@link #newHandle(int, String, String, String, boolean)}.
- */
- @Deprecated
- public int newHandle(final int tag, final String owner, final String name,
- final String desc) {
- return newHandle(tag, owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE);
- }
-
/**
* Adds a handle to the constant pool of the class being build. Does nothing
* if the constant pool already contains a similar item. This method is
diff --git a/src/org/redkale/asm/FieldVisitor.java b/src/org/redkale/asm/FieldVisitor.java
index 5876275fe..5bc0ead7b 100644
--- a/src/org/redkale/asm/FieldVisitor.java
+++ b/src/org/redkale/asm/FieldVisitor.java
@@ -101,9 +101,6 @@ public abstract class FieldVisitor {
* calls. May be null.
*/
public FieldVisitor(final int api, final FieldVisitor fv) {
- if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
- throw new IllegalArgumentException();
- }
this.api = api;
this.fv = fv;
}
@@ -145,9 +142,6 @@ public abstract class FieldVisitor {
*/
public AnnotationVisitor visitTypeAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (fv != null) {
return fv.visitTypeAnnotation(typeRef, typePath, desc, visible);
}
diff --git a/src/org/redkale/asm/Handle.java b/src/org/redkale/asm/Handle.java
index 6a35cf7d9..259feb217 100644
--- a/src/org/redkale/asm/Handle.java
+++ b/src/org/redkale/asm/Handle.java
@@ -99,34 +99,6 @@ public final class Handle {
*/
final boolean itf;
- /**
- * Constructs a new field or method handle.
- *
- * @param tag
- * the kind of field or method designated by this Handle. Must be
- * {@link Opcodes#H_GETFIELD}, {@link Opcodes#H_GETSTATIC},
- * {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC},
- * {@link Opcodes#H_INVOKEVIRTUAL},
- * {@link Opcodes#H_INVOKESTATIC},
- * {@link Opcodes#H_INVOKESPECIAL},
- * {@link Opcodes#H_NEWINVOKESPECIAL} or
- * {@link Opcodes#H_INVOKEINTERFACE}.
- * @param owner
- * the internal name of the class that owns the field or method
- * designated by this handle.
- * @param name
- * the name of the field or method designated by this handle.
- * @param desc
- * the descriptor of the field or method designated by this
- * handle.
- *
- * @deprecated this constructor has been superseded
- * by {@link #Handle(int, String, String, String, boolean)}.
- */
- @Deprecated
- public Handle(int tag, String owner, String name, String desc) {
- this(tag, owner, name, desc, tag == Opcodes.H_INVOKEINTERFACE);
- }
/**
* Constructs a new field or method handle.
diff --git a/src/org/redkale/asm/MethodVisitor.java b/src/org/redkale/asm/MethodVisitor.java
index 8295e8b1e..71303fe67 100644
--- a/src/org/redkale/asm/MethodVisitor.java
+++ b/src/org/redkale/asm/MethodVisitor.java
@@ -118,9 +118,6 @@ public abstract class MethodVisitor {
* calls. May be null.
*/
public MethodVisitor(final int api, final MethodVisitor mv) {
- if (api < Opcodes.ASM4 || api > Opcodes.ASM6) {
- throw new IllegalArgumentException();
- }
this.api = api;
this.mv = mv;
}
@@ -140,9 +137,6 @@ public abstract class MethodVisitor {
* allowed (see {@link Opcodes}).
*/
public void visitParameter(String name, int access) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (mv != null) {
mv.visitParameter(name, access);
}
@@ -209,9 +203,6 @@ public abstract class MethodVisitor {
*/
public AnnotationVisitor visitTypeAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (mv != null) {
return mv.visitTypeAnnotation(typeRef, typePath, desc, visible);
}
@@ -453,34 +444,6 @@ public abstract class MethodVisitor {
}
}
- /**
- * Visits a method instruction. A method instruction is an instruction that
- * invokes a method.
- *
- * @param opcode
- * the opcode of the type instruction to be visited. This opcode
- * is either INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or
- * INVOKEINTERFACE.
- * @param owner
- * the internal name of the method's owner class (see
- * {@link Type#getInternalName() getInternalName}).
- * @param name
- * the method's name.
- * @param desc
- * the method's descriptor (see {@link Type Type}).
- */
- @Deprecated
- public void visitMethodInsn(int opcode, String owner, String name,
- String desc) {
- if (api >= Opcodes.ASM5) {
- boolean itf = opcode == Opcodes.INVOKEINTERFACE;
- visitMethodInsn(opcode, owner, name, desc, itf);
- return;
- }
- if (mv != null) {
- mv.visitMethodInsn(opcode, owner, name, desc);
- }
- }
/**
* Visits a method instruction. A method instruction is an instruction that
@@ -502,14 +465,6 @@ public abstract class MethodVisitor {
*/
public void visitMethodInsn(int opcode, String owner, String name,
String desc, boolean itf) {
- if (api < Opcodes.ASM5) {
- if (itf != (opcode == Opcodes.INVOKEINTERFACE)) {
- throw new IllegalArgumentException(
- "INVOKESPECIAL/STATIC on interfaces require ASM 5");
- }
- visitMethodInsn(opcode, owner, name, desc);
- return;
- }
if (mv != null) {
mv.visitMethodInsn(opcode, owner, name, desc, itf);
}
@@ -723,9 +678,6 @@ public abstract class MethodVisitor {
*/
public AnnotationVisitor visitInsnAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (mv != null) {
return mv.visitInsnAnnotation(typeRef, typePath, desc, visible);
}
@@ -783,9 +735,6 @@ public abstract class MethodVisitor {
*/
public AnnotationVisitor visitTryCatchAnnotation(int typeRef,
TypePath typePath, String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (mv != null) {
return mv.visitTryCatchAnnotation(typeRef, typePath, desc, visible);
}
@@ -854,9 +803,6 @@ public abstract class MethodVisitor {
public AnnotationVisitor visitLocalVariableAnnotation(int typeRef,
TypePath typePath, Label[] start, Label[] end, int[] index,
String desc, boolean visible) {
- if (api < Opcodes.ASM5) {
- throw new RuntimeException();
- }
if (mv != null) {
return mv.visitLocalVariableAnnotation(typeRef, typePath, start,
end, index, desc, visible);
diff --git a/src/org/redkale/asm/Opcodes.java b/src/org/redkale/asm/Opcodes.java
index ccb07f345..94c0aa644 100644
--- a/src/org/redkale/asm/Opcodes.java
+++ b/src/org/redkale/asm/Opcodes.java
@@ -74,16 +74,10 @@ public interface Opcodes {
// ASM API versions
- int ASM4 = 4 << 16 | 0 << 8 | 0;
- int ASM5 = 5 << 16 | 0 << 8 | 0;
int ASM6 = 6 << 16 | 0 << 8 | 0;
// versions
- int V1_1 = 3 << 16 | 45;
- int V1_2 = 0 << 16 | 46;
- int V1_3 = 0 << 16 | 47;
- int V1_4 = 0 << 16 | 48;
int V1_5 = 0 << 16 | 49;
int V1_6 = 0 << 16 | 50;
int V1_7 = 0 << 16 | 51;
diff --git a/src/org/redkale/net/http/Rest.java b/src/org/redkale/net/http/Rest.java
index e30b11326..0fe202d48 100644
--- a/src/org/redkale/net/http/Rest.java
+++ b/src/org/redkale/net/http/Rest.java
@@ -96,7 +96,7 @@ public final class Rest {
String key = name + ":" + desc;
if (fieldmap.containsKey(key)) return null;
fieldmap.put(key, fieldnames);
- return new MethodVisitor(Opcodes.ASM5) {
+ return new MethodVisitor(Opcodes.ASM6) {
@Override
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, int index) {
if (index < 1) return;
@@ -119,7 +119,7 @@ public final class Rest {
InputStream in = clazz.getResourceAsStream(n.substring(n.lastIndexOf('.') + 1) + ".class");
if (in == null) return map;
try {
- new ClassReader(Utility.readBytesThenClose(in)).accept(new MethodParamClassVisitor(Opcodes.ASM5, map), 0);
+ new ClassReader(Utility.readBytesThenClose(in)).accept(new MethodParamClassVisitor(Opcodes.ASM6, map), 0);
} catch (Exception e) { //无需理会
}
Class superClass = clazz.getSuperclass();
diff --git a/src/org/redkale/util/Creator.java b/src/org/redkale/util/Creator.java
index c1eefa3b6..9e0857276 100644
--- a/src/org/redkale/util/Creator.java
+++ b/src/org/redkale/util/Creator.java
@@ -105,7 +105,7 @@ public interface Creator {
if (this.started) return null;
this.started = true;
//返回的List中参数列表可能会比方法参数量多,因为方法内的临时变量也会存入list中, 所以需要list的元素集合比方法的参数多
- return new MethodVisitor(Opcodes.ASM5) {
+ return new MethodVisitor(Opcodes.ASM6) {
@Override
public void visitLocalVariable(String name, String description, String signature, Label start, Label end, int index) {
if (index < 1) return;
@@ -139,7 +139,7 @@ public interface Creator {
return null;
}
final List fieldnames = new ArrayList<>();
- new ClassReader(out.toByteArray()).accept(new SimpleClassVisitor(Opcodes.ASM5, fieldnames, constructorDesc), 0);
+ new ClassReader(out.toByteArray()).accept(new SimpleClassVisitor(Opcodes.ASM6, fieldnames, constructorDesc), 0);
if (fieldnames.isEmpty()) return null;
if (paramcount == fieldnames.size()) {
return getConstructorField(clazz, paramcount, fieldnames.toArray(new String[fieldnames.size()]));