author | katleman |
Thu, 21 Aug 2014 14:16:14 -0700 | |
changeset 25878 | 6d561031123e |
parent 9600 | 1cfd668d5426 |
permissions | -rw-r--r-- |
9600
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
1 |
/* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
4 |
* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
8 |
* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
14 |
* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
18 |
* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
23 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
24 |
/* |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 7040104 |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
27 |
* @summary javac NPE on Object a[]; Object o = (a=null)[0]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
28 |
*/ |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
29 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
30 |
public class T7040104 { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
31 |
public static void main(String[] args) { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
32 |
T7040104 t = new T7040104(); |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
33 |
t.test1(); |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
34 |
t.test2(); |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
35 |
t.test3(); |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
36 |
if (t.npeCount != 3) { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
37 |
throw new AssertionError(); |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
38 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
39 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
40 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
41 |
int npeCount = 0; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
42 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
43 |
void test1() { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
44 |
Object a[]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
45 |
try { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
46 |
Object o = (a = null)[0]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
47 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
48 |
catch (NullPointerException npe) { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
49 |
npeCount++; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
50 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
51 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
52 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
53 |
void test2() { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
54 |
Object a[][]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
55 |
try { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
56 |
Object o = (a = null)[0][0]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
57 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
58 |
catch (NullPointerException npe) { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
59 |
npeCount++; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
60 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
61 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
62 |
|
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
63 |
void test3() { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
64 |
Object a[][][]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
65 |
try { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
66 |
Object o = (a = null)[0][0][0]; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
67 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
68 |
catch (NullPointerException npe) { |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
69 |
npeCount++; |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
70 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
71 |
} |
1cfd668d5426
7040104: javac NPE on Object a[]; Object o = (a=null)[0];
mcimadamore
parents:
diff
changeset
|
72 |
} |