Wed, 22 Jan 2014 12:37:28 -0800
Added tag jdk8u5-b05 for changeset b90de55aca30
kvn@2413 | 1 | /* |
kmo@4590 | 2 | * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
kvn@2413 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
kvn@2413 | 4 | * |
kvn@2413 | 5 | * This code is free software; you can redistribute it and/or modify it |
kvn@2413 | 6 | * under the terms of the GNU General Public License version 2 only, as |
kvn@2413 | 7 | * published by the Free Software Foundation. |
kvn@2413 | 8 | * |
kvn@2413 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
kvn@2413 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
kvn@2413 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
kvn@2413 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
kvn@2413 | 13 | * accompanied this code). |
kvn@2413 | 14 | * |
kvn@2413 | 15 | * You should have received a copy of the GNU General Public License version |
kvn@2413 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
kvn@2413 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
kvn@2413 | 18 | * |
kvn@2413 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
kvn@2413 | 20 | * or visit www.oracle.com if you need additional information or have any |
kvn@2413 | 21 | * questions. |
kvn@2413 | 22 | * |
kvn@2413 | 23 | */ |
kvn@2413 | 24 | |
kvn@2413 | 25 | /** |
kvn@2413 | 26 | * @test |
kvn@2413 | 27 | * @bug 7009359 |
kvn@2413 | 28 | * @summary HS with -XX:+AggressiveOpts optimize new StringBuffer(null) so it does not throw NPE as expected |
kvn@2413 | 29 | * |
kmo@4590 | 30 | * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+OptimizeStringConcat -XX:CompileCommand=dontinline,Test7009359,stringmakerBUG Test7009359 |
kvn@2413 | 31 | * |
kvn@2413 | 32 | */ |
kvn@2413 | 33 | |
kvn@2413 | 34 | public class Test7009359 { |
kvn@2413 | 35 | public static void main (String[] args) { |
kmo@4590 | 36 | for(int i = 0; i < 100000; i++) { |
kvn@2413 | 37 | if(!stringmakerBUG(null).equals("NPE")) { |
kvn@2413 | 38 | System.out.println("StringBuffer(null) does not throw NPE"); |
kvn@2413 | 39 | System.exit(97); |
kvn@2413 | 40 | } |
kvn@2413 | 41 | } |
kvn@2413 | 42 | } |
kvn@2413 | 43 | |
kvn@2413 | 44 | public static String stringmakerBUG(String str) { |
kvn@2413 | 45 | try { |
kvn@2413 | 46 | return new StringBuffer(str).toString(); |
kvn@2413 | 47 | } catch (NullPointerException e) { |
kvn@2413 | 48 | return "NPE"; |
kvn@2413 | 49 | } |
kvn@2413 | 50 | } |
kvn@2413 | 51 | } |
kvn@2413 | 52 |