6948381: javac Null Pointer Exception in Types.makeCompoundType
Race condition between symbol completion and attribution of import statements causes NPE when creating intersection type Reviewed-by: jjg
This commit is contained in:
parent
cd66a7b462
commit
56c4bf22d4
@ -1861,13 +1861,16 @@ public class Types {
|
||||
|
||||
/**
|
||||
* Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that
|
||||
* third parameter is computed directly. Note that this test
|
||||
* might cause a symbol completion. Hence, this version of
|
||||
* third parameter is computed directly, as follows: if all
|
||||
* all bounds are interface types, the computed supertype is Object,
|
||||
* otherwise the supertype is simply left null (in this case, the supertype
|
||||
* is assumed to be the head of the bound list passed as second argument).
|
||||
* Note that this check might cause a symbol completion. Hence, this version of
|
||||
* setBounds may not be called during a classfile read.
|
||||
*/
|
||||
public void setBounds(TypeVar t, List<Type> bounds) {
|
||||
Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ?
|
||||
supertype(bounds.head) : null;
|
||||
syms.objectType : null;
|
||||
setBounds(t, bounds, supertype);
|
||||
t.rank_field = -1;
|
||||
}
|
||||
|
29
langtools/test/tools/javac/6948381/T6948381.java
Normal file
29
langtools/test/tools/javac/6948381/T6948381.java
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 6948381
|
||||
* @summary javac Null Pointer Exception in Types.makeCompoundType
|
||||
* @compile npe/A.java npe/B.java
|
||||
*/
|
28
langtools/test/tools/javac/6948381/npe/A.java
Normal file
28
langtools/test/tools/javac/6948381/npe/A.java
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package npe;
|
||||
|
||||
import npe.B.*;
|
||||
|
||||
public interface A {}
|
26
langtools/test/tools/javac/6948381/npe/B.java
Normal file
26
langtools/test/tools/javac/6948381/npe/B.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010 Sun Microsystems, Inc. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
||||
* CA 95054 USA or visit www.sun.com if you need additional information or
|
||||
* have any questions.
|
||||
*/
|
||||
|
||||
package npe;
|
||||
|
||||
public interface B<T extends A & java.io.Serializable> {}
|
Loading…
x
Reference in New Issue
Block a user