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 173659 Details for
Bug 314556
[1.5][compiler] compiler fails to report attempt to assign weaker access privileges
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Revised patch
patch.txt (text/plain), 6.41 KB, created by
Srikanth Sankaran
on 2010-07-07 10:46:07 EDT
(
hide
)
Description:
Revised patch
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-07-07 10:46:07 EDT
Size:
6.41 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java,v >retrieving revision 1.112 >diff -u -r1.112 MethodVerifier15.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 23 Jun 2010 08:25:53 -0000 1.112 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java 7 Jul 2010 14:42:18 -0000 >@@ -541,6 +541,21 @@ > int count = index + 1; > while (--count > 0) { > MethodBinding match = matchingInherited[count]; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556 >+ MethodBinding interfaceMethod = null, implementation = null; >+ if (first.declaringClass.isInterface()) { >+ interfaceMethod = first; >+ } else if (first.declaringClass.isClass()) { >+ implementation = first; >+ } >+ if (match.declaringClass.isInterface()) { >+ interfaceMethod = match; >+ } else if (match.declaringClass.isClass()) { >+ implementation = match; >+ } >+ if (interfaceMethod != null && implementation != null && !isAsVisible(implementation, interfaceMethod)) >+ problemReporter().visibilityConflict(typeParameter, implementation, interfaceMethod); >+ > if (areReturnTypesCompatible(first, match)) continue; > // unrelated interfaces - check to see if return types are compatible > if (first.declaringClass.isInterface() && match.declaringClass.isInterface() && areReturnTypesCompatible(match, first)) >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.412 >diff -u -r1.412 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jul 2010 05:56:10 -0000 1.412 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 7 Jul 2010 14:42:22 -0000 >@@ -7430,10 +7430,21 @@ > // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method. > IProblem.MethodReducesVisibility, > new String[] {new String(inheritedMethod.declaringClass.readableName())}, >- new String[] {new String(inheritedMethod.declaringClass.shortReadableName())}, >+ new String[] {new String(""), new String(inheritedMethod.declaringClass.shortReadableName())}, //$NON-NLS-1$ > currentMethod.sourceStart(), > currentMethod.sourceEnd()); > } >+public void visibilityConflict(TypeParameter typeParameter, MethodBinding currentMethod, MethodBinding inheritedMethod) { >+ this.handle( >+ // Cannot reduce the visibility of the inherited method from %1 >+ // 8.4.6.3 - The access modifier of an hiding method must provide at least as much access as the hidden method. >+ // 8.4.6.3 - The access modifier of an overiding method must provide at least as much access as the overriden method. >+ IProblem.MethodReducesVisibility, >+ new String[] {new String(inheritedMethod.declaringClass.readableName())}, >+ new String[] {" " + new String(inheritedMethod.shortReadableName()), new String(inheritedMethod.declaringClass.shortReadableName())}, //$NON-NLS-1$ >+ typeParameter.sourceStart(), >+ typeParameter.sourceEnd()); >+} > public void wildcardAssignment(TypeBinding variableType, TypeBinding expressionType, ASTNode location) { > this.handle( > IProblem.WildcardFieldAssignment, >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.257 >diff -u -r1.257 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 4 Mar 2010 16:43:55 -0000 1.257 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 7 Jul 2010 14:42:23 -0000 >@@ -348,7 +348,7 @@ > 406 = This instance method cannot override the static method from {0} > 407 = This static method cannot hide the instance method from {0} > 408 = The static method {0} conflicts with the abstract method in {1} >-409 = Cannot reduce the visibility of the inherited method from {0} >+409 = Cannot reduce the visibility of the inherited method{0} from {1} > 410 = The method {0} does not override the inherited method from {1} since it is private to a different package > 411 = This class must implement the inherited abstract method {1}, but cannot override it since it is not visible from {0}. Either make the type abstract or make the inherited method visible > 412 = The method {0} overrides a deprecated method from {1} >#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.821 >diff -u -r1.821 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 24 Jun 2010 07:30:00 -0000 1.821 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 7 Jul 2010 14:42:49 -0000 >@@ -50513,4 +50513,22 @@ > "Type mismatch: cannot convert from AnotherClass<capture#1-of ? extends IReferencedInterface> to AnotherClass<IReferencedInterface>\n" + > "----------\n"); > } >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=314556 >+public void test1463() { >+ this.runNegativeTest( >+ new String[] { >+ "BaseType.java", >+ "public interface BaseType {\n" + >+ " BaseType clone() throws CloneNotSupportedException;\n" + >+ "}\n" + >+ "interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in BaseType.java (at line 4)\n" + >+ " interface SubType<T extends BaseType & java.io.Closeable> extends BaseType {\n" + >+ " ^\n" + >+ "Cannot reduce the visibility of the inherited method clone() from BaseType\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 314556
:
173634
|
173659
|
173837