From: rtrimana Date: Thu, 20 Jun 2019 17:48:38 +0000 (-0700) Subject: Adding a native method to handle getBounds() with a default answer: java.lang.Object X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d9d624b7b9c52392ff46ef55a52cc4da167a06b6;p=jpf-core.git Adding a native method to handle getBounds() with a default answer: java.lang.Object --- diff --git a/examples/Reflection.java b/examples/Reflection.java index 88f41d5..f2feb06 100644 --- a/examples/Reflection.java +++ b/examples/Reflection.java @@ -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); diff --git a/src/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java b/src/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java index c77a3a5..7abc7e3 100644 --- a/src/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java +++ b/src/classes/sun/reflect/generics/reflectiveObjects/TypeVariableImpl.java @@ -59,11 +59,11 @@ public class TypeVariableImpl return new TypeVariableImpl(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 index 0000000..79c4ae4 --- /dev/null +++ b/src/peers/gov/nasa/jpf/vm/JPF_sun_reflect_generics_reflectiveObjects_TypeVariableImpl.java @@ -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; + } +}