15f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray/* 25f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 35f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * 45f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 55f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * you may not use this file except in compliance with the License. 65f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * You may obtain a copy of the License at 75f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * 85f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 95f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * 105f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * Unless required by applicable law or agreed to in writing, software 115f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 125f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * See the License for the specific language governing permissions and 145f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * limitations under the License. 155f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray */ 165f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 175f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray/** 185f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray * Test that null pointer exceptions are thrown by the VM. 195f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray */ 205f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffraypublic class Main { 215f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray private int f; 225f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray public static void main(String[] args) { 235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray methodOne(); 245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 255f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 265f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void methodOne() { 275f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray methodTwo(); 285f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 295f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 305f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray private int callSpecial() { 315f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray return f; 325f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 335f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 345f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray final int callFinal() { 355f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray return f; 365f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 375f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 385f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void methodTwo() { 395f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray NullPointerException npe = null; 405f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 415f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray int thisLine = 41; 425f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 435f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray new Object().getClass(); // Ensure compiled. 445f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 455f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Object) null).getClass(); 465f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 475f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 485f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 495f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 4); 505f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 515f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray new Main().callSpecial(); // Ensure compiled. 525f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 535f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Main) null).callSpecial(); // Test invokespecial. 545f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 555f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 565f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 575f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 8); 585f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 595f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray new Main().callFinal(); // Ensure compiled. 605f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 615f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Main) null).callFinal(); // Test invokevirtual on final. 625f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 635f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 645f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 655f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 8); 665f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 675f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 685f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).objectField.toString(); 695f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 705f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 715f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 725f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 735f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 745f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 755f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((Value) null).intField); 765f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 775f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 785f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 795f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 805f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 815f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 825f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useFloat(((Value) null).floatField); 835f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 845f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 855f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 865f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 875f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 885f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 895f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useLong(((Value) null).longField); 905f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 915f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 925f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 935f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 945f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 955f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 965f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useDouble(((Value) null).doubleField); 975f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 985f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 995f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1005f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1015f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1025f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1035f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).objectField = "Fisk"; 1045f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1055f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1065f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1075f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1085f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1095f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1105f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).intField = 42; 1115f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1125f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1135f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1145f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1155f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1165f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1175f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).floatField = 42.0F; 1185f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1195f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1205f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1215f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1225f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).longField = 42L; 1255f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1265f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1275f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1285f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1295f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1305f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1315f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).doubleField = 42.0d; 1325f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1335f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1345f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1355f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1365f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1375f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1385f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((Value) null).byteField); 1395f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1405f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1415f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1425f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1435f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1445f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1455f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray if (((Value) null).booleanField) { } 1465f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1475f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1485f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1495f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1505f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1515f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1525f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((Value) null).charField); 1535f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1545f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1555f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1565f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1575f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1585f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1595f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((Value) null).shortField); 1605f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1615f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1625f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1635f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1645f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1655f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1665f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).byteField = 42; 1675f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1685f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1695f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1705f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1715f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1725f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1735f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).booleanField = true; 1745f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1755f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1765f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1775f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1785f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1795f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1805f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).charField = '\u0042'; 1815f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1825f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1835f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1845f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1855f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1865f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 1875f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Value) null).shortField = 42; 1885f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 1895f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 1905f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 1915f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 1925f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 1935f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 194ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileObjectField.toString(); 195ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 196ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 197ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 198ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 199ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 200ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 201ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileObjectField = "Fisk"; 202ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 203ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 204ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 205ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 206ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 207ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 208ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useInt(((Value) null).volatileIntField); 209ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 210ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 211ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 212ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 213ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 214ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 215ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileIntField = 42; 216ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 217ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 218ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 219ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 220ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 221ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 222ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useFloat(((Value) null).volatileFloatField); 223ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 224ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 225ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 226ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 227ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 228ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 229ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileFloatField = 42.0F; 230ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 231ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 232ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 233ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 234ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 235ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 236ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useLong(((Value) null).volatileLongField); 237ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 238ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 239ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 240ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 241ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 242ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 243ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileLongField = 42L; 244ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 245ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 246ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 247ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 248ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 249ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 250ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useDouble(((Value) null).volatileDoubleField); 251ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 252ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 253ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 254ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 255ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 256ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 257ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileDoubleField = 42.0d; 258ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 259ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 260ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 261ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 262ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 263ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 264ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useInt(((Value) null).volatileByteField); 265ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 266ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 267ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 268ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 269ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 270ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 271ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileByteField = 42; 272ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 273ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 274ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 275ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 276ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 277ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 278ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko if (((Value) null).volatileBooleanField) { } 279ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 280ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 281ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 282ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 283ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 284ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 285ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileBooleanField = true; 286ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 287ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 288ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 289ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 290ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 291ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 292ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useInt(((Value) null).volatileCharField); 293ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 294ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 295ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 296ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 297ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 298ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 299ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileCharField = '\u0042'; 300ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 301ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 302ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 303ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 304ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 305ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 306ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko useInt(((Value) null).volatileShortField); 307ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 308ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 309ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 310ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 311ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 312ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 313ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko ((Value) null).volatileShortField = 42; 314ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } catch (NullPointerException e) { 315ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko npe = e; 316ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko } 317ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko check(npe, thisLine += 7); 318ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 319ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko try { 3205f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Object[]) null)[0].toString(); 3215f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3225f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3255f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3265f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3275f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((int[]) null)[0]); 3285f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3295f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3305f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3315f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3325f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3335f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3345f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useFloat(((float[]) null)[0]); 3355f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3365f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3375f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3385f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3395f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3405f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3415f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useLong(((long[]) null)[0]); 3425f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3435f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3445f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3455f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3465f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3475f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3485f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useDouble(((double[]) null)[0]); 3495f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3505f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3515f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3525f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3535f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3545f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3555f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((Object[]) null)[0] = "Fisk"; 3565f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3575f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3585f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3595f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3605f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3615f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3625f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((int[]) null)[0] = 42; 3635f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3645f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3655f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3665f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3675f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3685f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3695f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((float[]) null)[0] = 42.0F; 3705f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3715f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3725f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3735f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3745f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3755f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3765f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((long[]) null)[0] = 42L; 3775f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3785f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3795f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3805f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3815f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3825f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3835f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((double[]) null)[0] = 42.0d; 3845f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3855f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3865f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3875f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3885f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3895f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3905f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((byte[]) null)[0]); 3915f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3925f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 3935f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 3945f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 3955f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 3965f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 3975f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray if (((boolean[]) null)[0]) { } 3985f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 3995f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4005f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4015f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4025f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4035f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4045f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((char[]) null)[0]); 4055f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4065f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4075f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4085f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4095f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4105f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4115f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((short[]) null)[0]); 4125f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4135f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4145f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4155f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4165f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4175f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4185f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((byte[]) null)[0] = 42; 4195f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4205f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4215f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4225f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4255f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((boolean[]) null)[0] = true; 4265f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4275f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4285f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4295f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4305f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4315f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4325f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((char[]) null)[0] = '\u0042'; 4335f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4345f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4355f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4365f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4375f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4385f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4395f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray ((short[]) null)[0] = 42; 4405f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4415f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4425f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4435f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4445f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4455f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4465f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((Object[]) null).length); 4475f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4485f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4495f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4505f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4515f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4525f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4535f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((int[]) null).length); 4545f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4555f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4565f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4575f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4585f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4595f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4605f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((float[]) null).length); 4615f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4625f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4635f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4645f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4655f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4665f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4675f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((long[]) null).length); 4685f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4695f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4705f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4715f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4725f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4735f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4745f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((double[]) null).length); 4755f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4765f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4775f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4785f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4795f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4805f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4815f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((byte[]) null).length); 4825f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4835f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4845f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4855f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4865f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4875f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4885f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((boolean[]) null).length); 4895f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4905f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4915f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4925f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 4935f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 4945f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 4955f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((char[]) null).length); 4965f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 4975f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 4985f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 4995f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 5005f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5015f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5025f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray useInt(((short[]) null).length); 5035f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 5045f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 5055f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5065f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 7); 5075f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5085f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5095f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray Interface i = null; 5105f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray i.methodInterface(); // Test null on invokeinterface. 5115f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 5125f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 5135f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5145f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 8); 5155f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5165f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5175f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray Object o = null; 5185f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray o.toString(); // Test null on invokevirtual. 5195f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 5205f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 5215f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5225f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 8); 5235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = null; 5255f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5265f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray String s = null; 5275f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5285f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray throw new AssertionError(); 5295f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } finally { 5305f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray // Cause an implicit NPE. 5315f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray s.getClass(); 5325f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5335f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 5345f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 5355f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5365f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 13); 5375f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5385f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = null; 5395f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5405f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray String s = null; 5415f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray try { 5425f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray throw new AssertionError(); 5435f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (AssertionError ex) { 5445f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5455f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray s.getClass(); 5465f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } catch (NullPointerException e) { 5475f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray npe = e; 5485f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5495f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray check(npe, thisLine += 14); 5505f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5515f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5525f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void check(NullPointerException npe, int firstLine) { 5535f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray final boolean debug = false; 5545f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray if (debug) { 5555f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray System.out.print("Got to line "); 5565f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray System.out.print(firstLine); 5575f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray System.out.println(); 5585f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5595f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray StackTraceElement[] trace = npe.getStackTrace(); 5605f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray checkElement(trace[0], "Main", "methodTwo", "Main.java", firstLine); 5615f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray checkElement(trace[1], "Main", "methodOne", "Main.java", 27); 5625f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray checkElement(trace[2], "Main", "main", "Main.java", 23); 5635f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5645f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5655f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void checkElement(StackTraceElement element, 5665f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray String declaringClass, String methodName, 5675f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray String fileName, int lineNumber) { 5685f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray assertEquals(declaringClass, element.getClassName()); 5695f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray assertEquals(methodName, element.getMethodName()); 5705f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray assertEquals(fileName, element.getFileName()); 5715f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray assertEquals(lineNumber, element.getLineNumber()); 5725f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5735f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5745f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void assertEquals(Object expected, Object actual) { 5755f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray if (!expected.equals(actual)) { 5765f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray String msg = "Expected \"" + expected + "\" but got \"" + actual + "\""; 5775f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray throw new AssertionError(msg); 5785f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5795f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5805f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5815f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void assertEquals(int expected, int actual) { 5825f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray if (expected != actual) { 5835f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray throw new AssertionError("Expected " + expected + " got " + actual); 5845f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5855f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5865f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5875f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray interface Interface { 5885f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray void methodInterface(); 5895f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5905f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5915f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void useInt(int i) { 5925f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5935f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5945f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void useFloat(float f) { 5955f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5965f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 5975f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void useDouble(double d) { 5985f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 5995f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 6005f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static void useLong(long l) { 6015f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 6025f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray 6035f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray static class Value { 6045f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray Object objectField; 6055f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray int intField; 606ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko float floatField; 607ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko long longField; 6085f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray double doubleField; 6095f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray byte byteField; 6105f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray boolean booleanField; 6115f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray char charField; 6125f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray short shortField; 613ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko 614ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile Object volatileObjectField; 615ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile int volatileIntField; 616ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile float volatileFloatField; 617ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile long volatileLongField; 618ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile double volatileDoubleField; 619ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile byte volatileByteField; 620ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile boolean volatileBooleanField; 621ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile char volatileCharField; 622ee5e273e4d0dd91b480c8d5dbcccad15c1b7353cVladimir Marko volatile short volatileShortField; 6235f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray } 6245f16c8838c8e4524101f5897dac70035c5cc271fNicolas Geoffray} 625