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 112814 Details for
Bug 247703
Removing internal superclass does not report error for removed methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed fix + regression tests
patch_247703.txt (text/plain), 12.63 KB, created by
Olivier Thomann
on 2008-09-17 15:47:31 EDT
(
hide
)
Description:
Proposed fix + regression tests
Filename:
MIME Type:
Creator:
Olivier Thomann
Created:
2008-09-17 15:47:31 EDT
Size:
12.63 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.api.tools >Index: src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools/src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java,v >retrieving revision 1.55 >diff -u -r1.55 ClassFileComparator.java >--- src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java 17 Sep 2008 15:44:01 -0000 1.55 >+++ src/org/eclipse/pde/api/tools/internal/comparator/ClassFileComparator.java 17 Sep 2008 19:46:06 -0000 >@@ -253,11 +253,6 @@ > if (visibilityModifiers == VisibilityModifiers.API) { > int currentTypeVisibility = 0; > String superTypeName = this.descriptor1.superName; >- String superTypeName2 = this.descriptor2.superName; >- if (!superTypeName.equals(superTypeName2)) { >- // we don't need to check the superclass if it has changed >- return; >- } > LookupResult pair = getType(superTypeName, this.component, this.apiProfile); > if (pair == null) return; > IClassFile superclassType1 = pair.classFile; >@@ -267,6 +262,49 @@ > if (superclassAnnotations != null) { > currentTypeVisibility = superclassAnnotations.getVisibility(); > if (!VisibilityModifiers.isAPI(currentTypeVisibility)) { >+ String superTypeName2 = this.descriptor2.superName; >+ if (!superTypeName.equals(superTypeName2)) { >+ // we don't need to check the superclass if it has changed >+ // all visible members (methods, fields and types) should be reported as removed >+ for (Iterator iterator = superTypeDescriptor.methods.values().iterator(); iterator.hasNext(); ) { >+ MethodDescriptor methodDescriptor = (MethodDescriptor) iterator.next(); >+ int access = methodDescriptor.access; >+ if (methodDescriptor.isClinit() >+ || methodDescriptor.isConstructor() >+ || Util.isDefault(access) >+ || Util.isPrivate(access) >+ || (Util.isProtected(access) >+ && RestrictionModifiers.isExtendRestriction(currentDescriptorRestrictions))) continue; >+ String methodDisplayName = getMethodDisplayName(methodDescriptor, this.descriptor1); >+ this.addDelta( >+ this.descriptor1.getElementType(), >+ IDelta.REMOVED, >+ IDelta.METHOD, >+ this.initialDescriptorRestrictions, >+ this.descriptor1.access, >+ this.classFile, >+ this.descriptor1.name, >+ new String[] {Util.getDescriptorName(this.descriptor1), methodDisplayName}); >+ } >+ for (Iterator iterator = superTypeDescriptor.fields.values().iterator(); iterator.hasNext(); ) { >+ FieldDescriptor fieldDescriptor = (FieldDescriptor) iterator.next(); >+ int access = fieldDescriptor.access; >+ if (Util.isDefault(access) >+ || Util.isPrivate(access) >+ || (Util.isProtected(access) >+ && RestrictionModifiers.isExtendRestriction(currentDescriptorRestrictions))) continue; >+ this.addDelta( >+ this.descriptor1.getElementType(), >+ IDelta.REMOVED, >+ IDelta.FIELD, >+ this.initialDescriptorRestrictions, >+ this.descriptor1.access, >+ this.classFile, >+ this.descriptor1.name, >+ new String[] {Util.getDescriptorName(this.descriptor1), fieldDescriptor.name}); >+ } >+ return; >+ } > // superclass is not an API type so we need to check it for visible members > // if this is an API, it will be checked when the supertype is checked > final boolean ignoreProtected = RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions) || Util.isFinal(this.descriptor1.access); >#P org.eclipse.pde.api.tools.tests >Index: src/org/eclipse/pde/api/tools/builder/tests/compatibility/ClassCompatibilityHierarchyTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/builder/tests/compatibility/ClassCompatibilityHierarchyTests.java,v >retrieving revision 1.8 >diff -u -r1.8 ClassCompatibilityHierarchyTests.java >--- src/org/eclipse/pde/api/tools/builder/tests/compatibility/ClassCompatibilityHierarchyTests.java 17 Sep 2008 18:21:22 -0000 1.8 >+++ src/org/eclipse/pde/api/tools/builder/tests/compatibility/ClassCompatibilityHierarchyTests.java 17 Sep 2008 19:46:06 -0000 >@@ -110,7 +110,15 @@ > setExpectedMessageArgs(args); > performCompatibilityTest(filePath, incremental); > } >+ >+ public void testRemoveIntSuperClassWithMethodI() throws Exception { >+ xRemoveIntSuperClassWithMethod(true); >+ } > >+ public void testRemoveIntSuperClassWithMethodF() throws Exception { >+ xRemoveIntSuperClassWithMethod(false); >+ } >+ > public void testReduceHierarchyCtoAI() throws Exception { > xReduceHierarchyCtoA(true); > } >@@ -265,7 +273,7 @@ > // no problems expected > performCompatibilityTest(filePath, incremental); > } >- >+ > public void testAddInterfaceAI() throws Exception { > xAddInterfaceA(true); > } >@@ -318,17 +326,16 @@ > */ > private void xRemoveIntSuperClassWithMethod(boolean incremental) throws Exception { > IPath filePath = WORKSPACE_CLASSES_PACKAGE_A.append("RemoveIntSuperClassWithMethod.java"); >- // TODO: expect a removed method problem >+ int[] ids = new int[] { >+ getRemovedProblemId(IDelta.METHOD) >+ }; >+ setExpectedProblemIds(ids); >+ String[][] args = new String[1][]; >+ args[0] = new String[]{PACKAGE_PREFIX + "RemoveIntSuperClassWithMethod", "method()"}; >+ setExpectedMessageArgs(args); > performCompatibilityTest(filePath, incremental); > } > >- public void testRemoveIntSuperClassWithMethodI() throws Exception { >- xRemoveIntSuperClassWithMethod(true); >- } >- >- public void testRemoveIntSuperClassWithMethodF() throws Exception { >- xRemoveIntSuperClassWithMethod(false); >- } > > /* (non-Javadoc) > * @see org.eclipse.pde.api.tools.builder.tests.ApiBuilderTest#getDefaultProblemId() >Index: src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.api.tools.tests/src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java,v >retrieving revision 1.25 >diff -u -r1.25 ClassDeltaTests.java >--- src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java 17 Sep 2008 18:37:33 -0000 1.25 >+++ src/org/eclipse/pde/api/tools/comparator/tests/ClassDeltaTests.java 17 Sep 2008 19:46:07 -0000 >@@ -34,9 +34,9 @@ > public class ClassDeltaTests extends DeltaTestSetup { > > public static Test suite() { >- if (true) return new TestSuite(ClassDeltaTests.class); >+ if (false) return new TestSuite(ClassDeltaTests.class); > TestSuite suite = new TestSuite(ClassDeltaTests.class.getName()); >- suite.addTest(new ClassDeltaTests("test138")); >+ suite.addTest(new ClassDeltaTests("test139")); > return suite; > } > >@@ -3229,4 +3229,26 @@ > assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); > assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); > assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); >- }} >\ No newline at end of file >+ } >+ /** >+ * Remove internal superclass that contains public method >+ */ >+ public void test139() { >+ deployBundles("test139"); >+ IApiProfile before = getBeforeState(); >+ IApiProfile after = getAfterState(); >+ IApiComponent beforeApiComponent = before.getApiComponent(BUNDLE_NAME); >+ assertNotNull("no api component", beforeApiComponent); >+ IApiComponent afterApiComponent = after.getApiComponent(BUNDLE_NAME); >+ assertNotNull("no api component", afterApiComponent); >+ IDelta delta = ApiComparator.compare(beforeApiComponent, afterApiComponent, before, after, VisibilityModifiers.API); >+ assertNotNull("No delta", delta); >+ IDelta[] allLeavesDeltas = collectLeaves(delta); >+ assertEquals("Wrong size", 1, allLeavesDeltas.length); >+ IDelta child = allLeavesDeltas[0]; >+ assertEquals("Wrong kind", IDelta.REMOVED, child.getKind()); >+ assertEquals("Wrong flag", IDelta.METHOD, child.getFlags()); >+ assertEquals("Wrong element type", IDelta.CLASS_ELEMENT_TYPE, child.getElementType()); >+ assertFalse("Is compatible", DeltaProcessor.isCompatible(child)); >+ } >+} >\ No newline at end of file >Index: tests-deltas/class/test139/before/p/X.java >=================================================================== >RCS file: tests-deltas/class/test139/before/p/X.java >diff -N tests-deltas/class/test139/before/p/X.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/before/p/X.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+package p; >+ >+public class X extends internal.p.Y {} >\ No newline at end of fileIndex: tests-deltas/class/test139/after/p/X.java >=================================================================== >RCS file: tests-deltas/class/test139/after/p/X.java >diff -N tests-deltas/class/test139/after/p/X.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/after/p/X.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+package p; >+ >+public class X {} >\ No newline at end of fileIndex: tests-deltas/class/test139/resources/after/META-INF/MANIFEST.MF >=================================================================== >RCS file: tests-deltas/class/test139/resources/after/META-INF/MANIFEST.MF >diff -N tests-deltas/class/test139/resources/after/META-INF/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/resources/after/META-INF/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,10 @@ >+Manifest-Version: 1.0 >+Ant-Version: Apache Ant 1.7.0 >+Created-By: 1.6.0_05-ea-b04 (Sun Microsystems Inc.) >+Bundle-ManifestVersion: 2 >+Bundle-Name: deltatest Plug-in >+Bundle-SymbolicName: deltatest >+Bundle-Version: 2.0.0 >+Bundle-RequiredExecutionEnvironment: J2SE-1.4 >+Export-Package: p, >+ internal.p;x-internal:=true >Index: tests-deltas/class/test139/resources/before/.api_description >=================================================================== >RCS file: tests-deltas/class/test139/resources/before/.api_description >diff -N tests-deltas/class/test139/resources/before/.api_description >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/resources/before/.api_description 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<component name="deltatest"> >+<plugin id="deltatest" /> >+</component> >\ No newline at end of fileIndex: tests-deltas/class/test139/resources/before/MANIFEST.MF >=================================================================== >RCS file: tests-deltas/class/test139/resources/before/MANIFEST.MF >diff -N tests-deltas/class/test139/resources/before/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/resources/before/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,10 @@ >+Manifest-Version: 1.0 >+Ant-Version: Apache Ant 1.7.0 >+Created-By: 1.6.0_05-ea-b04 (Sun Microsystems Inc.) >+Bundle-ManifestVersion: 2 >+Bundle-Name: deltatest Plug-in >+Bundle-SymbolicName: deltatest >+Bundle-Version: 1.0.0 >+Bundle-RequiredExecutionEnvironment: J2SE-1.4 >+Export-Package: p, >+ internal.p;x-internal:=true >Index: tests-deltas/class/test139/resources/after/.api_description >=================================================================== >RCS file: tests-deltas/class/test139/resources/after/.api_description >diff -N tests-deltas/class/test139/resources/after/.api_description >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/resources/after/.api_description 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,4 @@ >+<?xml version="1.0" encoding="UTF-8"?> >+<component name="deltatest"> >+<plugin id="deltatest" /> >+</component> >\ No newline at end of fileIndex: tests-deltas/class/test139/after/internal/p/Y.java >=================================================================== >RCS file: tests-deltas/class/test139/after/internal/p/Y.java >diff -N tests-deltas/class/test139/after/internal/p/Y.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/after/internal/p/Y.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,3 @@ >+package internal.p; >+ >+public class Y {} >\ No newline at end of fileIndex: tests-deltas/class/test139/before/internal/p/Y.java >=================================================================== >RCS file: tests-deltas/class/test139/before/internal/p/Y.java >diff -N tests-deltas/class/test139/before/internal/p/Y.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ tests-deltas/class/test139/before/internal/p/Y.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,5 @@ >+package internal.p; >+ >+public class Y { >+ public void bar() {} >+} >\ 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 247703
:
112814
|
115424