6860795: NullPointerException when compiling a negative java source

Wed, 15 Jul 2009 17:01:47 +0100

author
mcimadamore
date
Wed, 15 Jul 2009 17:01:47 +0100
changeset 326
90d40dd5cfc7
parent 325
ad07b7ea9685
child 327
86ad2753f3be

6860795: NullPointerException when compiling a negative java source
Summary: Rich formatter shouldn't propagate visits on method symbols that have a null type
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6860795/T6860795.java file | annotate | diff | comparison | revisions
test/tools/javac/Diagnostics/6860795/T6860795.out file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jul 15 10:25:01 2009 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Wed Jul 15 17:01:47 2009 +0100
     1.3 @@ -569,7 +569,8 @@
     1.4          @Override
     1.5          public Void visitMethodSymbol(MethodSymbol s, Void ignored) {
     1.6              visit(s.owner, null);
     1.7 -            typePreprocessor.visit(s.type);
     1.8 +            if (s.type != null)
     1.9 +                typePreprocessor.visit(s.type);
    1.10              return null;
    1.11          }
    1.12      };
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/tools/javac/Diagnostics/6860795/T6860795.java	Wed Jul 15 17:01:47 2009 +0100
     2.3 @@ -0,0 +1,34 @@
     2.4 +/*
     2.5 + * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
     2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2.7 + *
     2.8 + * This code is free software; you can redistribute it and/or modify it
     2.9 + * under the terms of the GNU General Public License version 2 only, as
    2.10 + * published by the Free Software Foundation.
    2.11 + *
    2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    2.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    2.15 + * version 2 for more details (a copy is included in the LICENSE file that
    2.16 + * accompanied this code).
    2.17 + *
    2.18 + * You should have received a copy of the GNU General Public License version
    2.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    2.21 + *
    2.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    2.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    2.24 + * have any questions.
    2.25 + */
    2.26 +
    2.27 +/**
    2.28 + * @test
    2.29 + * @bug     6860795
    2.30 + * @summary NullPointerException when compiling a negative java source
    2.31 + * @author  mcimadamore
    2.32 + * @compile/fail/ref=T6860795.out -XDrawDiagnostics  T6860795.java
    2.33 + */
    2.34 +
    2.35 +class Test {
    2.36 +    void foo(float x, int x) {}
    2.37 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/Diagnostics/6860795/T6860795.out	Wed Jul 15 17:01:47 2009 +0100
     3.3 @@ -0,0 +1,2 @@
     3.4 +T6860795.java:33:27: compiler.err.already.defined: x, foo
     3.5 +1 error

mercurial