UnderscoreAsIdent.java revision 2747:84a76798cff3
14Srgrimes/*
21549Srgrimes * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
31549Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44Srgrimes *
54Srgrimes * This code is free software; you can redistribute it and/or modify it
64Srgrimes * under the terms of the GNU General Public License version 2 only, as
74Srgrimes * published by the Free Software Foundation.
84Srgrimes *
94Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
104Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
114Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
124Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
134Srgrimes * accompanied this code).
144Srgrimes *
154Srgrimes * You should have received a copy of the GNU General Public License version
164Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
174Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
184Srgrimes *
194Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
204Srgrimes * or visit www.oracle.com if you need additional information or have any
214Srgrimes * questions.
224Srgrimes */
234Srgrimes
244Srgrimes/*
254Srgrimes * @test
264Srgrimes * @summary Check usages of underscore as identifier generate warnings
274Srgrimes * @compile/fail/ref=UnderscoreAsIdent8.out -source 8 -Xlint:-options -XDrawDiagnostics -Werror UnderscoreAsIdent.java
284Srgrimes * @compile/fail/ref=UnderscoreAsIdent9.out -XDrawDiagnostics -Werror UnderscoreAsIdent.java
294Srgrimes */
304Srgrimespackage _._;
314Srgrimes
324Srgrimesimport _._;
331549Srgrimes
344Srgrimesclass _ {
354Srgrimes    String _ = null;
36719Swollman    void _(String _) { }
37719Swollman    void testLocal() {
38719Swollman        String _ = null;
394Srgrimes    }
401549Srgrimes    void testFor() {
414Srgrimes        for (int _ = 0; _ < 10; _++);
424Srgrimes    }
431549Srgrimes    void testTry() {
444Srgrimes        try { } catch (Throwable _) { }
451549Srgrimes    }
461549Srgrimes    void testLabel() {
471549Srgrimes        _:
481549Srgrimes        for (;;) {
491549Srgrimes            break _;
501549Srgrimes        }
511549Srgrimes        _:
521549Srgrimes        for (;;) {
531549Srgrimes            continue _;
541549Srgrimes        }
551549Srgrimes    }
561549Srgrimes}
574Srgrimes