2 * Copyright (C) 2014, United States Government, as represented by the
3 * Administrator of the National Aeronautics and Space Administration.
6 * The Java Pathfinder core (jpf-core) platform is licensed under the
7 * Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0.
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 package gov.nasa.jpf.vm;
21 import gov.nasa.jpf.annotation.MJI;
24 public class JPF_gov_nasa_jpf_SerializationConstructor extends NativePeer {
27 * create a new instance, but only call the ctor of the first
28 * non-serializable superclass
31 public int newInstance___3Ljava_lang_Object_2__Ljava_lang_Object_2 (MJIEnv env, int mthRef, int argsRef) {
32 ThreadInfo ti = env.getThreadInfo();
33 DirectCallStackFrame frame = ti.getReturnedDirectCall();
35 int superCtorRef = env.getReferenceField(mthRef, "firstNonSerializableCtor");
36 MethodInfo miCtor = JPF_java_lang_reflect_Constructor.getMethodInfo(env,superCtorRef);
38 if (frame == null){ // first time
39 int clsRef = env.getReferenceField(mthRef, "mdc");
40 ClassInfo ci = env.getReferredClassInfo( clsRef);
43 env.throwException("java.lang.InstantiationException");
47 int objRef = env.newObjectOfUncheckedClass(ci);
48 frame = miCtor.createDirectCallStackFrame(ti, 1);
49 frame.setReferenceArgument( 0, objRef, null);
50 frame.setLocalReferenceVariable(0, objRef); // (1) we store the reference as a local var for retrieval during reexec
53 // check for & push required clinits
54 ci.initializeClass(ti);
55 env.repeatInvocation();
58 } else { // re-execution,
59 int objRef = frame.getLocalVariable(0); // that's the object ref we stored in (1)