1*795d594fSAndroid Build Coastguard Worker /* 2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2014 The Android Open Source Project 3*795d594fSAndroid Build Coastguard Worker * 4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*795d594fSAndroid Build Coastguard Worker * 8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*795d594fSAndroid Build Coastguard Worker * 10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*795d594fSAndroid Build Coastguard Worker * limitations under the License. 15*795d594fSAndroid Build Coastguard Worker */ 16*795d594fSAndroid Build Coastguard Worker 17*795d594fSAndroid Build Coastguard Worker public class Main extends TestCase { main(String[] args)18*795d594fSAndroid Build Coastguard Worker public static void main(String[] args) { 19*795d594fSAndroid Build Coastguard Worker $opt$TestThisClassStaticField(); 20*795d594fSAndroid Build Coastguard Worker $opt$TestOtherClassStaticField(); 21*795d594fSAndroid Build Coastguard Worker $opt$TestAddThisClassStaticField(); 22*795d594fSAndroid Build Coastguard Worker $opt$TestAddOtherClassStaticField(); 23*795d594fSAndroid Build Coastguard Worker $opt$TestOtherClassWithClinitStaticField(); 24*795d594fSAndroid Build Coastguard Worker $opt$TestAccess(); 25*795d594fSAndroid Build Coastguard Worker } 26*795d594fSAndroid Build Coastguard Worker 27*795d594fSAndroid Build Coastguard Worker static int staticField = 42; 28*795d594fSAndroid Build Coastguard Worker getInt()29*795d594fSAndroid Build Coastguard Worker static int getInt() { 30*795d594fSAndroid Build Coastguard Worker return 33; 31*795d594fSAndroid Build Coastguard Worker } 32*795d594fSAndroid Build Coastguard Worker $opt$TestThisClassStaticField()33*795d594fSAndroid Build Coastguard Worker static void $opt$TestThisClassStaticField() { 34*795d594fSAndroid Build Coastguard Worker assertEquals(42, staticField); 35*795d594fSAndroid Build Coastguard Worker } 36*795d594fSAndroid Build Coastguard Worker $opt$TestOtherClassStaticField()37*795d594fSAndroid Build Coastguard Worker static void $opt$TestOtherClassStaticField() { 38*795d594fSAndroid Build Coastguard Worker assertEquals(41, Other.staticField); 39*795d594fSAndroid Build Coastguard Worker } 40*795d594fSAndroid Build Coastguard Worker $opt$TestAddThisClassStaticField()41*795d594fSAndroid Build Coastguard Worker static void $opt$TestAddThisClassStaticField() { 42*795d594fSAndroid Build Coastguard Worker int a = getInt(); 43*795d594fSAndroid Build Coastguard Worker assertEquals(a + 42, a + staticField); 44*795d594fSAndroid Build Coastguard Worker } 45*795d594fSAndroid Build Coastguard Worker $opt$TestAddOtherClassStaticField()46*795d594fSAndroid Build Coastguard Worker static void $opt$TestAddOtherClassStaticField() { 47*795d594fSAndroid Build Coastguard Worker int a = getInt(); 48*795d594fSAndroid Build Coastguard Worker assertEquals(a + 41, a + Other.staticField); 49*795d594fSAndroid Build Coastguard Worker } 50*795d594fSAndroid Build Coastguard Worker $opt$TestOtherClassWithClinitStaticField()51*795d594fSAndroid Build Coastguard Worker static void $opt$TestOtherClassWithClinitStaticField() { 52*795d594fSAndroid Build Coastguard Worker assertEquals(40, OtherWithClinit.staticField); 53*795d594fSAndroid Build Coastguard Worker } 54*795d594fSAndroid Build Coastguard Worker $opt$TestAccess()55*795d594fSAndroid Build Coastguard Worker static void $opt$TestAccess() { 56*795d594fSAndroid Build Coastguard Worker assertEquals(false, sZ); 57*795d594fSAndroid Build Coastguard Worker assertEquals(0, sB); 58*795d594fSAndroid Build Coastguard Worker assertEquals(0, sC); 59*795d594fSAndroid Build Coastguard Worker assertEquals(0, sI); 60*795d594fSAndroid Build Coastguard Worker assertEquals(0, sJ); 61*795d594fSAndroid Build Coastguard Worker assertEquals(0, sS); 62*795d594fSAndroid Build Coastguard Worker assertEquals(0.0f, sF); 63*795d594fSAndroid Build Coastguard Worker assertEquals(0.0, sD); 64*795d594fSAndroid Build Coastguard Worker assertNull(sObject); 65*795d594fSAndroid Build Coastguard Worker 66*795d594fSAndroid Build Coastguard Worker long longValue = -1122198787987987987L; 67*795d594fSAndroid Build Coastguard Worker Object o = new Object(); 68*795d594fSAndroid Build Coastguard Worker sZ = true; 69*795d594fSAndroid Build Coastguard Worker sB = -2; 70*795d594fSAndroid Build Coastguard Worker sC = 'c'; 71*795d594fSAndroid Build Coastguard Worker sI = 42; 72*795d594fSAndroid Build Coastguard Worker sJ = longValue; 73*795d594fSAndroid Build Coastguard Worker sS = 68; 74*795d594fSAndroid Build Coastguard Worker sObject = o; 75*795d594fSAndroid Build Coastguard Worker sF = 2.3f; 76*795d594fSAndroid Build Coastguard Worker sD = 5.3; 77*795d594fSAndroid Build Coastguard Worker 78*795d594fSAndroid Build Coastguard Worker assertEquals(true, sZ); 79*795d594fSAndroid Build Coastguard Worker assertEquals(-2, sB); 80*795d594fSAndroid Build Coastguard Worker assertEquals('c', sC); 81*795d594fSAndroid Build Coastguard Worker assertEquals(42, sI); 82*795d594fSAndroid Build Coastguard Worker assertEquals(longValue, sJ); 83*795d594fSAndroid Build Coastguard Worker assertEquals(68, sS); 84*795d594fSAndroid Build Coastguard Worker assertEquals(o, sObject); 85*795d594fSAndroid Build Coastguard Worker assertEquals(2.3f, sF); 86*795d594fSAndroid Build Coastguard Worker assertEquals(5.3, sD); 87*795d594fSAndroid Build Coastguard Worker } 88*795d594fSAndroid Build Coastguard Worker 89*795d594fSAndroid Build Coastguard Worker static boolean sZ; 90*795d594fSAndroid Build Coastguard Worker static byte sB; 91*795d594fSAndroid Build Coastguard Worker static char sC; 92*795d594fSAndroid Build Coastguard Worker static double sD; 93*795d594fSAndroid Build Coastguard Worker static float sF; 94*795d594fSAndroid Build Coastguard Worker static int sI; 95*795d594fSAndroid Build Coastguard Worker static long sJ; 96*795d594fSAndroid Build Coastguard Worker static short sS; 97*795d594fSAndroid Build Coastguard Worker static Object sObject; 98*795d594fSAndroid Build Coastguard Worker } 99