Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 82458 Details for
Bug 209153
[1.5][compiler] VerifyError due to generic cast to a non visible type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for 3.3.x
209153-3.3.txt (text/plain), 16.49 KB, created by
Philipe Mulet
on 2007-11-08 11:35:01 EST
(
hide
)
Description:
Patch for 3.3.x
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-11-08 11:35:01 EST
Size:
16.49 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.97.2.1 >diff -u -r1.97.2.1 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 10 Oct 2007 08:20:15 -0000 1.97.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 8 Nov 2007 15:58:15 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.impl.*; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >@@ -228,6 +229,16 @@ > ? compileTimeType // unboxing: checkcast before conversion > : runtimeTimeType; > this.genericCast = originalType.genericCast(scope.boxing(targetType)); >+ if (this.genericCast instanceof ReferenceBinding) { >+ ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast; >+ if (!referenceCast.canBeSeenBy(scope)) { >+ scope.problemReporter().invalidType(this, >+ new ProblemReferenceBinding( >+ CharOperation.splitOn('.', referenceCast.shortReadableName()), >+ referenceCast, >+ ProblemReasons.NotVisible)); >+ } >+ } > } > } > super.computeConversion(scope, runtimeTimeType, compileTimeType); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v >retrieving revision 1.109.2.2 >diff -u -r1.109.2.2 FieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 25 Oct 2007 14:01:52 -0000 1.109.2.2 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 8 Nov 2007 15:58:15 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.impl.*; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >@@ -127,6 +128,16 @@ > ? compileTimeType // unboxing: checkcast before conversion > : runtimeTimeType; > this.genericCast = originalBinding.type.genericCast(targetType); >+ if (this.genericCast instanceof ReferenceBinding) { >+ ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast; >+ if (!referenceCast.canBeSeenBy(scope)) { >+ scope.problemReporter().invalidType(this, >+ new ProblemReferenceBinding( >+ CharOperation.splitOn('.', referenceCast.shortReadableName()), >+ referenceCast, >+ ProblemReasons.NotVisible)); >+ } >+ } > } > } > super.computeConversion(scope, runtimeTimeType, compileTimeType); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v >retrieving revision 1.122 >diff -u -r1.122 MessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 26 Apr 2007 21:03:26 -0000 1.122 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 8 Nov 2007 15:58:15 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.Scope; >@@ -98,7 +99,7 @@ > TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) > ? compileTimeType // unboxing: checkcast before conversion > : runtimeTimeType; >- this.valueCast = originalType.genericCast(targetType); >+ this.valueCast = originalType.genericCast(targetType); > } else if (this.actualReceiverType.isArrayType() > && runtimeTimeType.id != TypeIds.T_JavaLangObject > && this.binding.parameters == Binding.NO_PARAMETERS >@@ -107,6 +108,16 @@ > // from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast > this.valueCast = runtimeTimeType; > } >+ if (this.valueCast instanceof ReferenceBinding) { >+ ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast; >+ if (!referenceCast.canBeSeenBy(scope)) { >+ scope.problemReporter().invalidType(this, >+ new ProblemReferenceBinding( >+ CharOperation.splitOn('.', referenceCast.shortReadableName()), >+ referenceCast, >+ ProblemReasons.NotVisible)); >+ } >+ } > } > super.computeConversion(scope, runtimeTimeType, compileTimeType); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v >retrieving revision 1.116.2.1 >diff -u -r1.116.2.1 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 10 Oct 2007 08:20:15 -0000 1.116.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 8 Nov 2007 15:58:15 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.CodeStream; >@@ -25,6 +26,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.MethodScope; > import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.Scope; >@@ -351,7 +353,18 @@ > TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) > ? compileTimeType // unboxing: checkcast before conversion > : runtimeTimeType; >- setGenericCast(length, originalType.genericCast(targetType)); >+ TypeBinding typeCast = originalType.genericCast(targetType); >+ setGenericCast(length, typeCast); >+ if (typeCast instanceof ReferenceBinding) { >+ ReferenceBinding referenceCast = (ReferenceBinding) typeCast; >+ if (!referenceCast.canBeSeenBy(scope)) { >+ scope.problemReporter().invalidType(this, >+ new ProblemReferenceBinding( >+ CharOperation.splitOn('.', referenceCast.shortReadableName()), >+ referenceCast, >+ ProblemReasons.NotVisible)); >+ } >+ } > } > } > super.computeConversion(scope, runtimeTimeType, compileTimeType); >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.631.2.5 >diff -u -r1.631.2.5 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 2 Nov 2007 14:22:15 -0000 1.631.2.5 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 8 Nov 2007 15:58:30 -0000 >@@ -38884,5 +38884,219 @@ > "Bound mismatch: The generic method throwE(Object...) of type X is not applicable for the arguments (Object[]). The inferred type Object[] is not a valid substitute for the bounded parameter <E extends Exception>\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=208873 >+public void test1212() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public interface Loader {\n" + >+ " public <T extends Integer, K extends String> T load(final K key);\n" + >+ " }\n" + >+ " Loader loader;\n" + >+ " public <K extends String, T extends Integer> T get(final K key) {\n" + >+ " T data = this.loader.load(key);\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=208873 - variation >+public void test1213() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " <T, U extends T, V extends T> T cond1(boolean z, U x1, V x2) {\n" + >+ " return (z? x1: x2);\n" + >+ " }\n" + >+ "}\n", >+ }, >+ ""); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209153 >+public void test1214() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " p.A myA = new p.A();\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " Object o = myA.box.get(); // ok, since no generic cast actually inserted\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " }\n" + >+ "}\n", >+ "p/A.java", >+ "package p;\n" + >+ "public class A {\n" + >+ " public static class Box<T> {\n" + >+ " public T t;\n" + >+ " public void set(T t) { this.t = t; }\n" + >+ " public T get() { return this.t; }\n" + >+ " }\n" + >+ " private class P {\n" + >+ " public int pval;\n" + >+ " }\n" + >+ " public P p;\n" + >+ " public Box<P> box;\n" + >+ " public Box<P> getBox() { return this.box; }\n" + >+ " public A next;\n" + >+ " public A getNext() { return this;} \n" + >+ " public A() {\n" + >+ " this.box = new Box<P>();\n" + >+ " this.box.set(new P());\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 7)\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " ^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. WARNING in p\\A.java (at line 18)\n" + >+ " this.box.set(new P());\n" + >+ " ^^^^^^^\n" + >+ "Access to enclosing constructor A.P() is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209153 - variation >+public void test1215() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " p.A myA = new p.A();\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " Object o = myA.box.get(); // ok, since no generic cast actually inserted\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " }\n" + >+ "}\n", >+ "p/A.java", >+ "package p;\n" + >+ "public class A {\n" + >+ " public static class Box<T> {\n" + >+ " public T t;\n" + >+ " public void set(T t) { this.t = t; }\n" + >+ " public T get() { return this.t; }\n" + >+ " }\n" + >+ " protected class P {\n" + >+ " public int pval;\n" + >+ " }\n" + >+ " public P p;\n" + >+ " public Box<P> box;\n" + >+ " public Box<P> getBox() { return this.box; }\n" + >+ " public A next;\n" + >+ " public A getNext() { return this;} \n" + >+ " public A() {\n" + >+ " this.box = new Box<P>();\n" + >+ " this.box.set(new P());\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 7)\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " ^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=209153 - variation >+public void test1216() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " p.A myA = new p.A();\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " Object o = myA.box.get(); // ok, since no generic cast actually inserted\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " }\n" + >+ "}\n", >+ "p/A.java", >+ "package p;\n" + >+ "public class A {\n" + >+ " public static class Box<T> {\n" + >+ " public T t;\n" + >+ " public void set(T t) { this.t = t; }\n" + >+ " public T get() { return this.t; }\n" + >+ " }\n" + >+ " class P {\n" + >+ " public int pval;\n" + >+ " }\n" + >+ " public P p;\n" + >+ " public Box<P> box;\n" + >+ " public Box<P> getBox() { return this.box; }\n" + >+ " public A next;\n" + >+ " public A getNext() { return this;} \n" + >+ " public A() {\n" + >+ " this.box = new Box<P>();\n" + >+ " this.box.set(new P());\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 4)\n" + >+ " myA.p = myA.box.get(); // [msgSend] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " myA.p = myA.getBox().t;// [fieldRef] generic cast to P -> error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 7)\n" + >+ " myA.p = myA.box.t;// [qName] generic cast to P -> error\n" + >+ " ^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " int pval = myA.box.t.pval;// intermediate access through P already flagged as error\n" + >+ " ^^^^^^^^^^^^^^\n" + >+ "The type A.P is not visible\n" + >+ "----------\n"); >+} > > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 209153
:
82445
| 82458 |
82459