|
|
@@ -13,8 +13,10 @@ import net.ranides.assira.text.ResolveFormatUtils;
|
|
|
|
|
|
import org.hamcrest.CoreMatchers;
|
|
|
import org.junit.Assume;
|
|
|
+import org.junit.AssumptionViolatedException;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
+import java.lang.reflect.Type;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -31,39 +33,37 @@ public class RMethodTest {
|
|
|
|
|
|
private static final String RECORD_TYPE = "net.ranides.test.mockup.reflection.ForRMethod<java.lang.Float>$Record<java.lang.Double>";
|
|
|
|
|
|
-// @Test
|
|
|
-// public void testJVM1() {
|
|
|
-// try {
|
|
|
-// itestJVM1();
|
|
|
-// } catch (java.lang.reflect.GenericSignatureFormatError e) {
|
|
|
-// throw new AssumptionViolatedException("Detected JVM bug.", e);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// private void itestJVM1() {
|
|
|
-// // @todo (assira #9) JVM BUG :)
|
|
|
-//
|
|
|
-// // to zadziała
|
|
|
-// ForRMethod<Float> parent1 = new ForRMethod<Float>(){};
|
|
|
-// Object record1 = parent1.new Record<Double>(){};
|
|
|
-// Type type1 = record1.getClass().getGenericSuperclass();
|
|
|
-//
|
|
|
-// Assume.assumeThat(type1.toString(), CoreMatchers.equalTo(RECORD_TYPE));
|
|
|
-//
|
|
|
-// // Wyjątek jaki leci jest zaskakujący:
|
|
|
-// // java.lang.reflect.GenericSignatureFormatError: Signature Parse error:
|
|
|
-// // ; expected in signature of type variable named
|
|
|
-// // Remaining input: <captured wildcard>;>.Record<Ljava/lang/Double;>;
|
|
|
-//
|
|
|
-// // Nie nasza wina. Kompilator coś sobie źle generuje i JVM samo tego sparsować sobie nie potrafi.
|
|
|
-//
|
|
|
-// ForRMethod<? super Float> parent2 = new ForRMethod<Float>(){};
|
|
|
-// Object record2 = parent2.new Record<Double>(){};
|
|
|
-// Type type2 = record2.getClass().getGenericSuperclass();
|
|
|
-//
|
|
|
-// Assume.assumeThat(type2.toString(), CoreMatchers.equalTo(RECORD_TYPE));
|
|
|
-//
|
|
|
-// }
|
|
|
+ @Test
|
|
|
+ public void testJVM1() {
|
|
|
+ try {
|
|
|
+ itestJVM1();
|
|
|
+ } catch (java.lang.reflect.GenericSignatureFormatError e) {
|
|
|
+ throw new AssumptionViolatedException("Detected JVM bug.", e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void itestJVM1() {
|
|
|
+ // this declarations are correct
|
|
|
+ ForRMethod<Float> parent1 = new ForRMethod<Float>(){};
|
|
|
+ Object record1 = parent1.new Record<Double>(){};
|
|
|
+ Type type1 = record1.getClass().getGenericSuperclass();
|
|
|
+
|
|
|
+ Assume.assumeThat(type1.toString(), CoreMatchers.equalTo(RECORD_TYPE));
|
|
|
+
|
|
|
+ // Exception thrown from here is very suprising:
|
|
|
+ // java.lang.reflect.GenericSignatureFormatError: Signature Parse error:
|
|
|
+ // ; expected in signature of type variable named
|
|
|
+ // Remaining input: <captured wildcard>;>.Record<Ljava/lang/Double;>;
|
|
|
+
|
|
|
+ // It is not our fault. Compiler generates something wrong and JVM itself can parse it.
|
|
|
+
|
|
|
+ ForRMethod<? super Float> parent2 = new ForRMethod<Float>(){};
|
|
|
+ Object record2 = parent2.new Record<Double>(){};
|
|
|
+ Type type2 = record2.getClass().getGenericSuperclass();
|
|
|
+
|
|
|
+ Assume.assumeThat(type2.toString(), CoreMatchers.equalTo(RECORD_TYPE));
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
@Test
|
|
|
public void testJVM2() {
|