Created
February 25, 2012 06:28
-
-
Save zakki/1906913 to your computer and use it in GitHub Desktop.
Overload & generics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Make implements Opcodes { | |
public static void main(String[] args) { | |
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS); | |
cw.visit(V1_1, ACC_PUBLIC, "test/Ov", null, "java/lang/Object", null); | |
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, | |
"<init>", | |
"()V", | |
null, | |
null); | |
mv.visitVarInsn(ALOAD, 0); | |
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V"); | |
mv.visitInsn(RETURN); | |
mv.visitMaxs(1, 1); | |
mv.visitEnd(); | |
mv = cw.visitMethod(ACC_PUBLIC, "a", "()Ljava/util/List;", "()Ljava/util/List<Ljava/lang/Integer;>;", null); | |
mv.visitMethodInsn(INVOKESTATIC, "java/util/Collections", "emptyList", "()Ljava/util/List;"); | |
mv.visitInsn(ARETURN); | |
mv.visitMaxs(0, 0); | |
mv.visitEnd(); | |
mv = cw.visitMethod(ACC_PUBLIC, "a", "()Ljava/util/List;", "()Ljava/util/List<Ljava/lang/Boolean;>;", null); | |
mv.visitMethodInsn(INVOKESTATIC, "java/util/Collections", "emptyList", "()Ljava/util/List;"); | |
mv.visitInsn(ARETURN); | |
mv.visitMaxs(0, 0); | |
mv.visitEnd(); | |
try { | |
FileOutputStream out = new FileOutputStream("lib/test/Ov.class"); | |
out.write(cw.toByteArray()); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment