1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dxc.junit.opcodes.invokeinterface.jm; 18 19 20 public class T_invokeinterface_19 implements Runnable, ITest { 21 public final static int CNT = 1000; 22 int value = 0; 23 boolean failed = false; 24 25 public void run() { 26 for(int i = 0; i < CNT; i++) { 27 doit(); 28 } 29 } 30 31 public synchronized void doit(){ 32 value++; 33 int c = value; 34 Thread.yield(); 35 if(c != value) 36 failed = true; 37 } 38 public void doit(int i){ 39 } 40 public void doitNative(){ 41 } 42 public int test(int a) { 43 return 0; 44 } 45 public int testArgsOrder(int a, int b){ 46 return 0; 47 } 48 49 public static boolean execute() { 50 T_invokeinterface_19 test = new T_invokeinterface_19(); 51 Thread t1 = new Thread(test); 52 Thread t2 = new Thread(test); 53 54 t1.start(); 55 t2.start(); 56 57 try 58 { 59 Thread.sleep(5000); 60 } 61 catch(InterruptedException ie) { 62 return false; 63 } 64 65 if(test.value != CNT * 2) 66 return false; 67 return !test.failed; 68 } 69 }