core: fix encoded value parser for signed and floating point numbers
This commit is contained in:
@@ -28,6 +28,12 @@ public abstract class AbstractTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertEquals(float a1, float a2) {
|
||||
if (Float.compare(a1, a2) != 0) {
|
||||
throw new AssertionError(a1 + " != " + a2);
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertEquals(Object a1, Object a2) {
|
||||
if (a1 == null) {
|
||||
if (a2 != null)
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package jadx.samples;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
public class TestAnnotationsParser extends AbstractTest {
|
||||
|
||||
@Target({ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public static @interface A {
|
||||
int i();
|
||||
|
||||
float f();
|
||||
}
|
||||
|
||||
@A(i = -1, f = C1.FLOAT_CONST)
|
||||
public static class C1 {
|
||||
public static final float FLOAT_CONST = 3.14f;
|
||||
}
|
||||
|
||||
@A(i = -1025, f = C2.FLOAT_CONST)
|
||||
public static class C2 {
|
||||
public static final float FLOAT_CONST = 0xFF0000;
|
||||
}
|
||||
|
||||
public boolean testRun() {
|
||||
A c1 = C1.class.getAnnotation(A.class);
|
||||
assertEquals(c1.i(), -1);
|
||||
assertEquals(c1.f(), C1.FLOAT_CONST);
|
||||
|
||||
A c2 = C2.class.getAnnotation(A.class);
|
||||
assertEquals(c2.i(), -1025);
|
||||
assertEquals(c2.f(), C2.FLOAT_CONST);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new TestAnnotationsParser().testRun();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user