Adding a native method to handle getBounds() with a default answer: java.lang.Object
authorrtrimana <rtrimana@uci.edu>
Thu, 20 Jun 2019 17:48:38 +0000 (10:48 -0700)
committerrtrimana <rtrimana@uci.edu>
Thu, 20 Jun 2019 17:48:38 +0000 (10:48 -0700)
examples/Reflection.java
src/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java
src/peers/gov/nasa/jpf/vm/JPF_sun_reflect_generics_reflectiveObjects_TypeVariableImpl.java [new file with mode: 0644]

index 88f41d555257c6e0fbae9fe898f9225fb289d3b8..f2feb06eaf5491190945dfd566f69f6dc075dcd7 100644 (file)
@@ -62,7 +62,12 @@ public class Reflection {
  
       }
       System.out.println();
-      
+
+      Type[] bounds = typeParameters[0].getBounds();
+      for (Type bound : bounds) {
+          System.out.println(bound);
+      }
+      System.out.println();
       Type returnType = methods[0].getGenericReturnType();
       System.out.println(returnType);
          
index c77a3a516323003565c5b07e88c8a9594c372d62..7abc7e3654ba499f48a3a436d69396ee809ea6a8 100644 (file)
@@ -59,11 +59,11 @@ public class TypeVariableImpl<D extends GenericDeclaration>
         return new TypeVariableImpl<T>(decl, name, bs, f);
     }
 
-    public Type[] getBounds() {
+    public native Type[] getBounds();
+    /*public Type[] getBounds() {
 
         throw new UnsupportedOperationException();
-        //return new Type[0];
-    }
+    }*/
 
     public D getGenericDeclaration(){
         throw new UnsupportedOperationException();
diff --git a/src/peers/gov/nasa/jpf/vm/JPF_sun_reflect_generics_reflectiveObjects_TypeVariableImpl.java b/src/peers/gov/nasa/jpf/vm/JPF_sun_reflect_generics_reflectiveObjects_TypeVariableImpl.java
new file mode 100644 (file)
index 0000000..79c4ae4
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014, United States Government, as represented by the
+ * Administrator of the National Aeronautics and Space Administration.
+ * All rights reserved.
+ *
+ * The Java Pathfinder core (jpf-core) platform is licensed under the
+ * Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0.
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package gov.nasa.jpf.vm;
+
+import gov.nasa.jpf.annotation.MJI;
+
+public class JPF_sun_reflect_generics_reflectiveObjects_TypeVariableImpl extends NativePeer {
+
+    @MJI
+    public int getBounds_____3Ljava_lang_reflect_Type_2 (MJIEnv env, int objRef){
+        ThreadInfo ti = env.getThreadInfo();
+        ClassInfo ci = ClassLoaderInfo.getCurrentResolvedClassInfo("java.lang.Object");
+        if (!ci.isRegistered()) {
+            ci.registerClass(ti);
+        }
+        int refObj = ci.getClassObjectRef();
+
+        int aRef = env.newObjectArray("Ljava/lang/reflect/Type;", 1);
+        // Set references for every array element
+        env.setReferenceArrayElement(aRef, 0, refObj);
+
+        return aRef;
+    }
+}