# HG changeset patch # User mcimadamore # Date 1274283786 -3600 # Node ID 313b819dbcc29c2bb4c9cb0e9f8ab17dc8c956d7 # Parent c9e7ce44b1733339209d96a7ba368abf52054f08 6948381: javac Null Pointer Exception in Types.makeCompoundType Summary: Race condition between symbol completion and attribution of import statements causes NPE when creating intersection type Reviewed-by: jjg diff -r c9e7ce44b173 -r 313b819dbcc2 langtools/src/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed May 19 16:42:37 2010 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Wed May 19 16:43:06 2010 +0100 @@ -1861,13 +1861,16 @@ /** * 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 bounds) { Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ? - supertype(bounds.head) : null; + syms.objectType : null; setBounds(t, bounds, supertype); t.rank_field = -1; } diff -r c9e7ce44b173 -r 313b819dbcc2 langtools/test/tools/javac/6948381/T6948381.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6948381/T6948381.java Wed May 19 16:43:06 2010 +0100 @@ -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 + */ diff -r c9e7ce44b173 -r 313b819dbcc2 langtools/test/tools/javac/6948381/npe/A.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6948381/npe/A.java Wed May 19 16:43:06 2010 +0100 @@ -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 {} diff -r c9e7ce44b173 -r 313b819dbcc2 langtools/test/tools/javac/6948381/npe/B.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6948381/npe/B.java Wed May 19 16:43:06 2010 +0100 @@ -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 {}