String annotation reading/writing

This commit is contained in:
Adam
2015-11-20 15:52:22 -05:00
parent 859f2d1dde
commit 4c0d8de65b
7 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
package net.runelite.deob.annotations;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import net.runelite.deob.ClassFile;
import net.runelite.deob.ClassGroup;
import org.junit.Assert;
import org.junit.Test;
public class AnnotationTest
{
@Test
public void testAnnotation() throws Exception
{
InputStream in = this.getClass().getClassLoader().getResourceAsStream("net/runelite/deob/annotations/TestClass.class");
Assert.assertNotNull(in);
ClassGroup group = new ClassGroup();
ClassFile cf = new ClassFile(group, new DataInputStream(in));
group.addClass(cf);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(bout);
cf.write(out); // write it out
// parse it again
cf = new ClassFile(group, new DataInputStream(new ByteArrayInputStream(bout.toByteArray())));
System.out.println(cf);
}
}

View File

@@ -0,0 +1,10 @@
package net.runelite.deob.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation
{
String value();
}

View File

@@ -0,0 +1,10 @@
package net.runelite.deob.annotations;
public class TestClass
{
@MyAnnotation("field1")
public int field1;
@MyAnnotation("method1")
public void method1() { }
}