View | Details | Raw Unified | Return to bug 239229 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/PackageBinding.java (-8 / +16 lines)
Lines 165-184 Link Here
165
public Binding getTypeOrPackage(char[] name) {
165
public Binding getTypeOrPackage(char[] name) {
166
	ReferenceBinding referenceBinding = getType0(name);
166
	ReferenceBinding referenceBinding = getType0(name);
167
	if (referenceBinding != null && referenceBinding != LookupEnvironment.TheNotFoundType) {
167
	if (referenceBinding != null && referenceBinding != LookupEnvironment.TheNotFoundType) {
168
		referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.environment, false /* no raw conversion for now */);
168
		if ((referenceBinding.tagBits & TagBits.HasMissingType) == 0) {
169
		if (referenceBinding.isNestedType())
169
			referenceBinding = (ReferenceBinding) BinaryTypeBinding.resolveType(referenceBinding, this.environment, false /* no raw conversion for now */);
170
			return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided);
170
			if (referenceBinding.isNestedType()) {
171
		return referenceBinding;
171
				return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided);
172
			}
173
			return referenceBinding;
174
		}
172
	}
175
	}
173
176
174
	PackageBinding packageBinding = getPackage0(name);
177
	PackageBinding packageBinding = getPackage0(name);
175
	if (packageBinding != null && packageBinding != LookupEnvironment.TheNotFoundPackage)
178
	if (packageBinding != null && packageBinding != LookupEnvironment.TheNotFoundPackage) {
176
		return packageBinding;
179
		return packageBinding;
177
180
	}
178
	if (referenceBinding == null) { // have not looked for it before
181
	if (referenceBinding == null) { // have not looked for it before
179
		if ((referenceBinding = this.environment.askForType(this, name)) != null) {
182
		if ((referenceBinding = this.environment.askForType(this, name)) != null) {
180
			if (referenceBinding.isNestedType())
183
			if (referenceBinding.isNestedType()) {
181
				return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided);
184
				return new ProblemReferenceBinding(new char[][]{name}, referenceBinding, ProblemReasons.InternalNameProvided);
185
			}
182
			return referenceBinding;
186
			return referenceBinding;
183
		}
187
		}
184
188
Lines 188-195 Link Here
188
	}
192
	}
189
193
190
	if (packageBinding == null) { // have not looked for it before
194
	if (packageBinding == null) { // have not looked for it before
191
		if ((packageBinding = findPackage(name)) != null)
195
		if ((packageBinding = findPackage(name)) != null) {
192
			return packageBinding;
196
			return packageBinding;
197
		}
198
		if (referenceBinding != null && referenceBinding != LookupEnvironment.TheNotFoundType) {
199
			return referenceBinding; // found cached missing type - check if package conflict
200
		}
193
		addNotFoundPackage(name);
201
		addNotFoundPackage(name);
194
	}
202
	}
195
203
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java (+323 lines)
Lines 11-16 Link Here
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.util.Map;
14
15
15
import junit.framework.Test;
16
import junit.framework.Test;
16
17
Lines 20-25 Link Here
20
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
21
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
22
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader;
22
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
23
import org.eclipse.jdt.internal.compiler.env.IBinaryMethod;
24
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
23
25
24
public class ProblemTypeAndMethodTest extends AbstractRegressionTest {
26
public class ProblemTypeAndMethodTest extends AbstractRegressionTest {
25
public ProblemTypeAndMethodTest(String name) {
27
public ProblemTypeAndMethodTest(String name) {
Lines 3794-3797 Link Here
3794
			"IOException cannot be resolved to a type\n" +
3796
			"IOException cannot be resolved to a type\n" +
3795
			"----------\n");
3797
			"----------\n");
3796
}
3798
}
3799
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758
3800
public void test081() {
3801
	if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
3802
	Map customOptions = getCompilerOptions();
3803
	customOptions.put(	CompilerOptions.OPTION_DocCommentSupport, CompilerOptions.ENABLED);	
3804
	customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadoc, CompilerOptions.ERROR);
3805
	customOptions.put(CompilerOptions.OPTION_ReportInvalidJavadocTags, CompilerOptions.ENABLED);
3806
	this.runNegativeTest(
3807
			new String[] {
3808
				"com/ost/util/report/Matrix.java", // =================
3809
				"package com.ost.util.report;\n" + 
3810
				"import java.io.Serializable;\n" + 
3811
				"import com.ost.util.report.exceptions.InvalidRowSizeException;\n" + 
3812
				"public class Matrix<T> implements Serializable {\n" + 
3813
				"	/**\n" + 
3814
				"	 * @see exceptions.InvalidRowSizeException2\n" + 
3815
				"	 */\n" + 
3816
				"	public synchronized final void addRow(Object[] row){\n" + 
3817
				"			throw new InvalidRowSizeException();\n" + 
3818
				"	}\n" + 
3819
				"}\n",
3820
				"com/ost/util/report/FilterConstraintSpecification.java", // =================
3821
				"package com.ost.util.report;\n" + 
3822
				"import java.io.Serializable;\n" + 
3823
				"import com.ost.util.report.exceptions.MalformedFilterConstraintSpecification;\n" + 
3824
				"public final class FilterConstraintSpecification implements Serializable, Cloneable {\n" + 
3825
				"	private final void makeConstraint(){\n" + 
3826
				"		throw new MalformedFilterConstraintSpecification();\n" + 
3827
				"	}\n" + 
3828
				"}\n",
3829
				"com/ost/util/report/exceptions/MalformedFilterConstraintSpecification.java", // =================
3830
				"package com.ost.util.report.exceptions;\n" + 
3831
				"public class MalformedFilterConstraintSpecification extends RuntimeException {\n" + 
3832
				"	/** Creates a new instance of MalformedFilterConstraintSpecification */\n" + 
3833
				"	public MalformedFilterConstraintSpecification() {\n" + 
3834
				"		super();\n" + 
3835
				"	}\n" + 
3836
				"	/* Creates a new instance of MalformedFilterConstraintSpecification */\n" + 
3837
				"	public MalformedFilterConstraintSpecification(String message) {\n" + 
3838
				"		super(message);\n" + 
3839
				"	}\n" + 
3840
				"}\n",
3841
				"com/ost/util/report/exceptions/InvalidRowSizeException.java", // =================
3842
				"package com.ost.util.report.exceptions;\n" + 
3843
				"public class InvalidRowSizeException extends RuntimeException {\n" + 
3844
				"	/** Creates a new instance of InvalidRowSizeException */\n" + 
3845
				"	public InvalidRowSizeException() {\n" + 
3846
				"		super();\n" + 
3847
				"	}\n" + 
3848
				"	/* Creates a new instance of InvalidRowSizeException */\n" + 
3849
				"	public InvalidRowSizeException(String message) {\n" + 
3850
				"		super(message);\n" + 
3851
				"	}\n" + 
3852
				"}\n"				
3853
			},
3854
			"----------\n" + 
3855
			"1. WARNING in com\\ost\\util\\report\\Matrix.java (at line 4)\n" + 
3856
			"	public class Matrix<T> implements Serializable {\n" + 
3857
			"	             ^^^^^^\n" + 
3858
			"The serializable class Matrix does not declare a static final serialVersionUID field of type long\n" + 
3859
			"----------\n" + 
3860
			"2. ERROR in com\\ost\\util\\report\\Matrix.java (at line 6)\n" + 
3861
			"	* @see exceptions.InvalidRowSizeException2\n" + 
3862
			"	       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3863
			"Javadoc: exceptions cannot be resolved to a type\n" + 
3864
			"----------\n" + 
3865
			"----------\n" + 
3866
			"1. WARNING in com\\ost\\util\\report\\FilterConstraintSpecification.java (at line 4)\n" + 
3867
			"	public final class FilterConstraintSpecification implements Serializable, Cloneable {\n" + 
3868
			"	                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3869
			"The serializable class FilterConstraintSpecification does not declare a static final serialVersionUID field of type long\n" + 
3870
			"----------\n" + 
3871
			"2. WARNING in com\\ost\\util\\report\\FilterConstraintSpecification.java (at line 5)\n" + 
3872
			"	private final void makeConstraint(){\n" + 
3873
			"	                   ^^^^^^^^^^^^^^^^\n" + 
3874
			"The method makeConstraint() from the type FilterConstraintSpecification is never used locally\n" + 
3875
			"----------\n" + 
3876
			"----------\n" + 
3877
			"1. WARNING in com\\ost\\util\\report\\exceptions\\MalformedFilterConstraintSpecification.java (at line 2)\n" + 
3878
			"	public class MalformedFilterConstraintSpecification extends RuntimeException {\n" + 
3879
			"	             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3880
			"The serializable class MalformedFilterConstraintSpecification does not declare a static final serialVersionUID field of type long\n" + 
3881
			"----------\n" + 
3882
			"----------\n" + 
3883
			"1. WARNING in com\\ost\\util\\report\\exceptions\\InvalidRowSizeException.java (at line 2)\n" + 
3884
			"	public class InvalidRowSizeException extends RuntimeException {\n" + 
3885
			"	             ^^^^^^^^^^^^^^^^^^^^^^^\n" + 
3886
			"The serializable class InvalidRowSizeException does not declare a static final serialVersionUID field of type long\n" + 
3887
			"----------\n",
3888
			null,
3889
			false,
3890
			customOptions);
3891
}
3892
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
3893
public void test082() {
3894
	if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
3895
	this.runConformTest(
3896
			new String[] {
3897
				"com/ost/util/report/Matrix.java", // =================
3898
				"package com.ost.util.report;\n" + 
3899
				"import java.io.Serializable;\n" + 
3900
				"import com.ost.util.report.exceptions.InvalidRowSizeException;\n" + 
3901
				"public class Matrix<T> implements Serializable {\n" + 
3902
				"	/**\n" + 
3903
				"	 * @see exceptions.InvalidRowSizeException2\n" + 
3904
				"	 */\n" + 
3905
				"	public synchronized final void addRow(Object[] row){\n" + 
3906
				"			throw new InvalidRowSizeException();\n" + 
3907
				"	}\n" + 
3908
				"}\n",
3909
				"com/ost/util/report/FilterConstraintSpecification.java", // =================
3910
				"package com.ost.util.report;\n" + 
3911
				"import java.io.Serializable;\n" + 
3912
				"import com.ost.util.report.exceptions.MalformedFilterConstraintSpecification;\n" + 
3913
				"public final class FilterConstraintSpecification implements Serializable, Cloneable {\n" + 
3914
				"	private final void makeConstraint(){\n" + 
3915
				"		throw new MalformedFilterConstraintSpecification();\n" + 
3916
				"	}\n" + 
3917
				"}\n",
3918
				"com/ost/util/report/exceptions/MalformedFilterConstraintSpecification.java", // =================
3919
				"package com.ost.util.report.exceptions;\n" + 
3920
				"public class MalformedFilterConstraintSpecification extends RuntimeException {\n" + 
3921
				"	/** Creates a new instance of MalformedFilterConstraintSpecification */\n" + 
3922
				"	public MalformedFilterConstraintSpecification() {\n" + 
3923
				"		super();\n" + 
3924
				"	}\n" + 
3925
				"	/* Creates a new instance of MalformedFilterConstraintSpecification */\n" + 
3926
				"	public MalformedFilterConstraintSpecification(String message) {\n" + 
3927
				"		super(message);\n" + 
3928
				"	}\n" + 
3929
				"}\n",
3930
				"com/ost/util/report/exceptions/InvalidRowSizeException.java", // =================
3931
				"package com.ost.util.report.exceptions;\n" + 
3932
				"public class InvalidRowSizeException extends RuntimeException {\n" + 
3933
				"	/** Creates a new instance of InvalidRowSizeException */\n" + 
3934
				"	public InvalidRowSizeException() {\n" + 
3935
				"		super();\n" + 
3936
				"	}\n" + 
3937
				"	/* Creates a new instance of InvalidRowSizeException */\n" + 
3938
				"	public InvalidRowSizeException(String message) {\n" + 
3939
				"		super(message);\n" + 
3940
				"	}\n" + 
3941
				"}\n"				
3942
			},
3943
			"");
3944
}
3945
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
3946
public void test083() {
3947
	this.runConformTest(
3948
			new String[] {
3949
				"foo/X.java", // =================
3950
				"package foo;\n" + 
3951
				"import foo.exceptions.*;\n" + 
3952
				"public class X {\n" + 
3953
				"  class exceptions {}\n" + 
3954
				"  exceptions E;\n" + 
3955
				"}\n",
3956
				"foo/exceptions/Z.java", // =================
3957
				"package foo.exceptions;\n" + 
3958
				"public class Z {\n" + 
3959
				"}\n"			
3960
			},
3961
			"");
3962
}
3963
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
3964
public void test084() {
3965
	this.runNegativeTest(
3966
			new String[] {
3967
				"foo/X.java", // =================
3968
				"package foo;\n" + 
3969
				"import foo.exceptions.*;\n" + 
3970
				"public class X {\n" + 
3971
				"  exceptions E;\n" + 
3972
				"}\n" +
3973
				"class exceptions {}\n",
3974
				"foo/exceptions/Z.java", // =================
3975
				"package foo.exceptions;\n" + 
3976
				"public class Z {\n" + 
3977
				"}\n"			
3978
			},
3979
			"----------\n" + 
3980
			"1. WARNING in foo\\X.java (at line 2)\n" + 
3981
			"	import foo.exceptions.*;\n" + 
3982
			"	       ^^^^^^^^^^^^^^\n" + 
3983
			"The import foo.exceptions is never used\n" + 
3984
			"----------\n" + 
3985
			"----------\n" + 
3986
			"1. ERROR in foo\\exceptions\\Z.java (at line 1)\n" + 
3987
			"	package foo.exceptions;\n" + 
3988
			"	        ^^^^^^^^^^^^^^\n" + 
3989
			"The package foo.exceptions collides with a type\n" + 
3990
			"----------\n");
3991
}
3992
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
3993
public void test085() {
3994
	this.runNegativeTest(
3995
			new String[] {
3996
				"p/X.java", // =================
3997
				"package p;\n" + 
3998
				"public class X extends zork.Z {\n" + 
3999
				"}\n",
4000
				"p/Y.java", // =================
4001
				"package p;\n" + 
4002
				"import p.zork.Z;\n" + 
4003
				"public class Y {\n" + 
4004
				"}\n",
4005
				"p/zork/Z.java", // =================
4006
				"package p.zork;\n" + 
4007
				"public class Z {\n" + 
4008
				"}\n"
4009
			},
4010
			"----------\n" + 
4011
			"1. ERROR in p\\X.java (at line 2)\n" + 
4012
			"	public class X extends zork.Z {\n" + 
4013
			"	                       ^^^^\n" + 
4014
			"zork cannot be resolved to a type\n" + 
4015
			"----------\n" + 
4016
			"----------\n" + 
4017
			"1. WARNING in p\\Y.java (at line 2)\n" + 
4018
			"	import p.zork.Z;\n" + 
4019
			"	       ^^^^^^^^\n" + 
4020
			"The import p.zork.Z is never used\n" + 
4021
			"----------\n");
4022
}
4023
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
4024
public void test086() {
4025
	this.runNegativeTest(
4026
			new String[] {
4027
				"p/X.java", // =================
4028
				"package p;\n" + 
4029
				"public class X extends zork.Z {\n" + 
4030
				"}\n",
4031
				"p/Y.java", // =================
4032
				"package p;\n" + 
4033
				"import p.zork.*;\n" + 
4034
				"public class Y {\n" + 
4035
				"}\n",
4036
				"p/zork/Z.java", // =================
4037
				"package p.zork;\n" + 
4038
				"public class Z {\n" + 
4039
				"}\n"
4040
			},
4041
			"----------\n" + 
4042
			"1. ERROR in p\\X.java (at line 2)\n" + 
4043
			"	public class X extends zork.Z {\n" + 
4044
			"	                       ^^^^\n" + 
4045
			"zork cannot be resolved to a type\n" + 
4046
			"----------\n" + 
4047
			"----------\n" + 
4048
			"1. WARNING in p\\Y.java (at line 2)\n" + 
4049
			"	import p.zork.*;\n" + 
4050
			"	       ^^^^^^\n" + 
4051
			"The import p.zork is never used\n" + 
4052
			"----------\n");
4053
}
4054
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
4055
public void test087() {
4056
	if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
4057
	this.runNegativeTest(
4058
			new String[] {
4059
				"p/X.java", // =================
4060
				"package p;\n" + 
4061
				"public class X extends zork.Z {\n" + 
4062
				"}\n",
4063
				"p/Y.java", // =================
4064
				"package p;\n" + 
4065
				"import static p.zork.Z.M;\n" + 
4066
				"public class Y {\n" + 
4067
				"}\n",
4068
				"p/zork/Z.java", // =================
4069
				"package p.zork;\n" + 
4070
				"public class Z {\n" + 
4071
				"	public static class M {}\n" +
4072
				"}\n"
4073
			},
4074
			"----------\n" + 
4075
			"1. ERROR in p\\X.java (at line 2)\n" + 
4076
			"	public class X extends zork.Z {\n" + 
4077
			"	                       ^^^^\n" + 
4078
			"zork cannot be resolved to a type\n" + 
4079
			"----------\n" + 
4080
			"----------\n" + 
4081
			"1. WARNING in p\\Y.java (at line 2)\n" + 
4082
			"	import static p.zork.Z.M;\n" + 
4083
			"	              ^^^^^^^^^^\n" + 
4084
			"The import p.zork.Z.M is never used\n" + 
4085
			"----------\n");
4086
}
4087
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=239758 - variation
4088
public void test088() {
4089
	if (this.complianceLevel <= ClassFileConstants.JDK1_4) return;
4090
	this.runNegativeTest(
4091
			new String[] {
4092
				"p/X.java", // =================
4093
				"package p;\n" + 
4094
				"public class X extends zork.Z {\n" + 
4095
				"}\n",
4096
				"p/Y.java", // =================
4097
				"package p;\n" + 
4098
				"import static p.zork.Z.*;\n" + 
4099
				"public class Y {\n" + 
4100
				"}\n",
4101
				"p/zork/Z.java", // =================
4102
				"package p.zork;\n" + 
4103
				"public class Z {\n" + 
4104
				"	static class M {}\n" +
4105
				"}\n"
4106
			},
4107
			"----------\n" + 
4108
			"1. ERROR in p\\X.java (at line 2)\n" + 
4109
			"	public class X extends zork.Z {\n" + 
4110
			"	                       ^^^^\n" + 
4111
			"zork cannot be resolved to a type\n" + 
4112
			"----------\n" + 
4113
			"----------\n" + 
4114
			"1. WARNING in p\\Y.java (at line 2)\n" + 
4115
			"	import static p.zork.Z.*;\n" + 
4116
			"	              ^^^^^^^^\n" + 
4117
			"The import p.zork.Z is never used\n" + 
4118
			"----------\n");
4119
}
3797
}
4120
}

Return to bug 239229