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.multiProcess;
21 import gov.nasa.jpf.util.test.TestMultiProcessJPF;
22 import gov.nasa.jpf.vm.MethodInfo;
24 import java.lang.reflect.Method;
25 import java.util.List;
27 import org.junit.Test;
30 * @author Nastaran Shafiei <nastaran.shafiei@gmail.com>
32 public class MethodTest extends TestMultiProcessJPF {
33 public native void keepMethod(Method m, int prcId);
35 // To check the type safe cloning of methods
37 public void methodCloneTest() throws SecurityException, NoSuchMethodException {
39 JPF_gov_nasa_jpf_vm_multiProcess_MethodTest.resetPrcIds();
42 if (mpVerifyNoPropertyViolation(2)) {
43 Method m = MethodTest.class.getMethod("methodCloneTest", new Class[]{});
44 int prcId = getProcessId();
49 List<MethodInfo> methods = JPF_gov_nasa_jpf_vm_multiProcess_MethodTest.getMethods();
50 assertEquals(methods.size(), 2);
51 assertTrue(methods.get(0)!=methods.get(1));
56 public void methodDeclaringClassTest() throws SecurityException, NoSuchMethodException {
57 if (mpVerifyNoPropertyViolation(2)) {
58 Class<?> cls = MethodTest.class;
60 // The loader of this class should be the same as the loader that loads
61 // the class java.lang.Thread within this process
62 assertEquals(cls.getClassLoader(), ClassLoader.getSystemClassLoader());
63 for(Method m: cls.getDeclaredMethods()) {
64 assertEquals(m.getDeclaringClass(), cls);