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 106055 Details for
Bug 238484
[1.5][compiler] Eclipse generates bad code (major regression)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for 3.4.x
238484-34x.txt (text/plain), 13.56 KB, created by
Philipe Mulet
on 2008-06-27 19:00:25 EDT
(
hide
)
Description:
Patch for 3.4.x
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-06-27 19:00:25 EDT
Size:
13.56 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: buildnotes_jdt-core.html >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v >retrieving revision 1.6530.2.12 >diff -u -r1.6530.2.12 buildnotes_jdt-core.html >--- buildnotes_jdt-core.html 25 Jun 2008 15:40:31 -0000 1.6530.2.12 >+++ buildnotes_jdt-core.html 27 Jun 2008 22:48:49 -0000 >@@ -51,7 +51,9 @@ > </ul> > > <h3>Problem Reports Fixed</h3> >-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=235882">235882</a> >+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=238484">238484</a> >+[1.5][compiler] Eclipse generates bad code (major regression) >+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=235882">235882</a> > [compiler] constructor-scoped inner classes unable to recognize final member variable initialization > <br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=235921">235921</a> > [1.5][compiler] Incorrect generic signature attribute created for inner anonymous type >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.333.2.1 >diff -u -r1.333.2.1 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 25 Jun 2008 15:40:28 -0000 1.333.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 27 Jun 2008 22:49:06 -0000 >@@ -3462,8 +3462,8 @@ > MethodBinding current = moreSpecific[i]; > if (current != null) { > ReferenceBinding[] mostSpecificExceptions = null; >- SimpleSet possibleMethods = null; > MethodBinding original = current.original(); >+ boolean shouldIntersectExceptions = original.declaringClass.isInterface() && original.thrownExceptions != Binding.NO_EXCEPTIONS; // only needed when selecting from interface methods > for (int j = 0; j < visibleSize; j++) { > MethodBinding next = moreSpecific[j]; > if (next == null || i == j) continue; >@@ -3527,58 +3527,44 @@ > // 15.12.2 > continue nextSpecific; // choose original2 instead > } >- if (original.thrownExceptions != original2.thrownExceptions) { >- if (mostSpecificExceptions == null) >- mostSpecificExceptions = original.thrownExceptions; >- if (possibleMethods == null) >- possibleMethods = new SimpleSet(3); >- int mostSpecificLength = mostSpecificExceptions.length; >- int original2Length = original2.thrownExceptions.length; >- SimpleSet temp = new SimpleSet(mostSpecificLength); >- nextException : for (int t = 0; t < mostSpecificLength; t++) { >- ReferenceBinding exception = mostSpecificExceptions[t]; >- for (int s = 0; s < original2Length; s++) { >- if (exception.isCompatibleWith(original2.thrownExceptions[s])) { >- possibleMethods.add(current); >- temp.add(exception); >- continue nextException; >- } else if (original2.thrownExceptions[s].isCompatibleWith(exception)) { >- possibleMethods.add(next); >- temp.add(original2.thrownExceptions[s]); >- continue nextException; >+ if (shouldIntersectExceptions && original2.declaringClass.isInterface()) { >+ if (original.thrownExceptions != original2.thrownExceptions) { >+ if (original2.thrownExceptions == Binding.NO_EXCEPTIONS) { >+ mostSpecificExceptions = Binding.NO_EXCEPTIONS; >+ } else { >+ if (mostSpecificExceptions == null) { >+ mostSpecificExceptions = original.thrownExceptions; >+ } >+ int mostSpecificLength = mostSpecificExceptions.length; >+ int original2Length = original2.thrownExceptions.length; >+ SimpleSet temp = new SimpleSet(mostSpecificLength); >+ boolean changed = false; >+ nextException : for (int t = 0; t < mostSpecificLength; t++) { >+ ReferenceBinding exception = mostSpecificExceptions[t]; >+ for (int s = 0; s < original2Length; s++) { >+ if (exception.isCompatibleWith(original2.thrownExceptions[s])) { >+ temp.add(exception); >+ continue nextException; >+ } else if (original2.thrownExceptions[s].isCompatibleWith(exception)) { >+ temp.add(original2.thrownExceptions[s]); >+ changed = true; >+ continue nextException; >+ } else { >+ changed = true; >+ } >+ } >+ } >+ if (changed) { >+ mostSpecificExceptions = temp.elementSize == 0 ? Binding.NO_EXCEPTIONS : new ReferenceBinding[temp.elementSize]; >+ temp.asArray(mostSpecificExceptions); > } > } > } >- mostSpecificExceptions = temp.elementSize == 0 ? Binding.NO_EXCEPTIONS : new ReferenceBinding[temp.elementSize]; >- temp.asArray(mostSpecificExceptions); > } > } > } >- if (mostSpecificExceptions != null) { >- Object[] values = possibleMethods.values; >- int exceptionLength = mostSpecificExceptions.length; >- nextMethod : for (int p = 0, vLength = values.length; p < vLength; p++) { >- MethodBinding possible = (MethodBinding) values[p]; >- if (possible == null) continue nextMethod; >- ReferenceBinding[] itsExceptions = possible.thrownExceptions; >- if (itsExceptions.length == exceptionLength) { >- nextException : for (int e = 0; e < exceptionLength; e++) { >- ReferenceBinding exception = itsExceptions[e]; >- for (int f = 0; f < exceptionLength; f++) >- if (exception == mostSpecificExceptions[f]) continue nextException; >- continue nextMethod; >- } >- return possible; >- } >- } >- return new MethodBinding( >- current.modifiers | ClassFileConstants.AccSynthetic, >- current.selector, >- current.returnType, >- current.parameters, >- mostSpecificExceptions, >- current.declaringClass >- ); >+ if (mostSpecificExceptions != null && mostSpecificExceptions != current.thrownExceptions) { >+ return new MostSpecificExceptionMethodBinding(current, mostSpecificExceptions); > } > return current; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java >=================================================================== >RCS file: compiler/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java >diff -N compiler/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MostSpecificExceptionMethodBinding.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,35 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2008 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 >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.compiler.lookup; >+ >+/** >+ * Pseudo method binding used to wrapper a real method, and expose less exceptions than original. >+ * For other protocols, it should delegate to original method >+ */ >+public class MostSpecificExceptionMethodBinding extends MethodBinding { >+ >+ private MethodBinding originalMethod; >+ >+ public MostSpecificExceptionMethodBinding (MethodBinding originalMethod, ReferenceBinding[] mostSpecificExceptions) { >+ super( >+ originalMethod.modifiers, >+ originalMethod.selector, >+ originalMethod.returnType, >+ originalMethod.parameters, >+ mostSpecificExceptions, >+ originalMethod.declaringClass); >+ this.originalMethod = originalMethod; >+ } >+ >+ public MethodBinding original() { >+ return this.originalMethod.original(); >+ } >+} >#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.727.2.1 >diff -u -r1.727.2.1 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 25 Jun 2008 15:40:24 -0000 1.727.2.1 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 27 Jun 2008 22:51:07 -0000 >@@ -45360,4 +45360,159 @@ > "Zork cannot be resolved to a type\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=238484 >+public void test1350() { >+ this.runConformTest( >+ new String[] { >+ "X.java", // ================= >+ "import java.io.IOException;\n" + >+ "\n" + >+ "interface TreeVisitor<T, U> {\n" + >+ " public T visit(U location);\n" + >+ "}\n" + >+ "\n" + >+ "interface TreeVisitable<U> {\n" + >+ " public <T> T visit(TreeVisitor<T, U> visitor) throws IOException;\n" + >+ "}\n" + >+ "\n" + >+ "abstract class Param implements TreeVisitable<Param> {\n" + >+ " public final Param lookforParam(final String name) {\n" + >+ " TreeVisitor<Param, Param> visitor = new TreeVisitor<Param, Param>() {\n" + >+ " public Param visit(Param location) {\n" + >+ " return null;\n" + >+ " }\n" + >+ " };\n" + >+ " return visit(visitor);\n" + >+ " }\n" + >+ "\n" + >+ " public abstract <T> T visit(TreeVisitor<T, Param> visitor);\n" + >+ "}\n" + >+ "\n" + >+ "class StructParam extends Param {\n" + >+ " public <T> T visit(TreeVisitor<T, Param> visitor) {\n" + >+ " return null;\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " StructParam p = new StructParam();\n" + >+ " p.lookforParam(\"abc\");\n" + >+ " System.out.println(\"done\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "done"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=238484 - variation >+public void test1351() { >+ this.runConformTest( >+ new String[] { >+ "X.java", // ================= >+ "import java.io.IOException;\n" + >+ "\n" + >+ "interface IFoo {\n" + >+ " <T> T foo(T t) throws IOException;\n" + >+ "}\n" + >+ "interface JFoo {\n" + >+ " <T> T foo(T t) throws Exception;\n" + >+ "}\n" + >+ "abstract class Foo implements IFoo, JFoo {}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Foo f = createFoo();\n" + >+ " try {\n" + >+ " f.foo(null);\n" + >+ " } catch(IOException e) {\n" + >+ " }\n" + >+ " System.out.println(\"done\");\n" + >+ " }\n" + >+ " static Foo createFoo() {\n" + >+ " return new Foo() {\n" + >+ " public <T> T foo(T t) {\n" + >+ " return t;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "done"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=238484 - variation >+public void test1352() { >+ this.runConformTest( >+ new String[] { >+ "X.java", // ================= >+ "import java.io.IOException;\n" + >+ "\n" + >+ "interface IFoo<U> {\n" + >+ " <T> T foo(T t) throws IOException;\n" + >+ "}\n" + >+ "interface JFoo<U> {\n" + >+ " <T> T foo(T t) throws Exception;\n" + >+ "}\n" + >+ "abstract class Foo implements IFoo<String>, JFoo<String> {}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Foo f = createFoo();\n" + >+ " try {\n" + >+ " f.foo(null);\n" + >+ " } catch(IOException e) {\n" + >+ " }\n" + >+ " System.out.println(\"done\"); //dd\n" + >+ " }\n" + >+ " static Foo createFoo() {\n" + >+ " return new Foo() {\n" + >+ " public <T> T foo(T t) {\n" + >+ " return t;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "done"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=238484 - variation >+public void test1353() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", // ================= >+ "import java.io.IOException;\n" + >+ "\n" + >+ "interface IFoo<U> {\n" + >+ " <T> T foo(T t) throws IOException;\n" + >+ "}\n" + >+ "interface JFoo<U> {\n" + >+ " <T> T foo(T t);\n" + >+ "}\n" + >+ "abstract class Foo implements IFoo<String>, JFoo<String> {}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " Foo f = createFoo();\n" + >+ " try {\n" + >+ " f.foo(null);\n" + >+ " } catch(IOException e) {\n" + >+ " }\n" + >+ " System.out.println(\"done\"); //dd\n" + >+ " }\n" + >+ " static Foo createFoo() {\n" + >+ " return new Foo() {\n" + >+ " public <T> T foo(T t) {\n" + >+ " return t;\n" + >+ " }\n" + >+ " };\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 16)\n" + >+ " } catch(IOException e) {\n" + >+ " ^^^^^^^^^^^\n" + >+ "Unreachable catch block for IOException. This exception is never thrown from the try statement body\n" + >+ "----------\n"); >+} >+ > } >\ No newline at end of file
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 238484
:
106030
|
106050
|
106052
| 106055