Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java,v --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 18 Mar 2010 16:22:38 -0000 1.50 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedTypeReference.java 5 Dec 2010 17:35:31 -0000 @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for Bug 331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -84,7 +85,7 @@ return this.resolvedType; if (i == 0 && this.resolvedType.isTypeVariable() && ((TypeVariableBinding) this.resolvedType).firstBound == null) { // cannot select from a type variable scope.problemReporter().illegalAccessFromTypeVariable((TypeVariableBinding) this.resolvedType, this); - return null; + return new ProblemReferenceBinding(this.tokens, scope.environment().createMissingType(null, this.tokens), ProblemReasons.NotFound); } if (i <= last && isTypeUseDeprecated(this.resolvedType, scope)) { reportDeprecatedType(this.resolvedType, scope, i); Index: src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java,v --- src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 27 Aug 2009 15:26:58 -0000 1.28 +++ src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 5 Dec 2010 17:35:32 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,6 +7,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Stephan Herrmann - Contribution for Bug 331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; import java.io.File; @@ -544,4 +545,37 @@ assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput); } } + +// https://bugs.eclipse.org/331872 - [compiler] NPE in Scope.createArrayType when attempting qualified access from type parameter +public void test018() throws Exception { + if (new CompilerOptions(getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_5) + return; + this.runNegativeTest( + new String[] { + "X.java", + "public class X

{\n" + + " void foo(p.O[] elems) {\n" + + " }\n" + + " void bar() {\n" + + " foo(new Object[0]);\n" + + " }\n" + + "}\n", + }, + "----------\n" + + "1. ERROR in X.java (at line 2)\n" + + " void foo(p.O[] elems) {\n" + + " ^^^^^\n" + + "Illegal qualified access from the type parameter p\n" + + "----------\n" + + "2. ERROR in X.java (at line 2)\n" + + " void foo(p.O[] elems) {\n" + + " ^^^\n" + + "p.O cannot be resolved to a type\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " foo(new Object[0]);\n" + + " ^^^\n" + + "The method foo(O[]) from the type X

refers to the missing type O\n" + + "----------\n"); +} }