Skip to content

Commit

Permalink
Revert "#363 added METHOD_DEFAULT_NOW_STATIC"
Browse files Browse the repository at this point in the history
This reverts commit 9118a7c.
  • Loading branch information
siom79 committed Sep 29, 2023
1 parent 9c92a1f commit 9d3997b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 102 deletions.
6 changes: 0 additions & 6 deletions japicmp-testbase/japicmp-test-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,6 @@
<sourceCompatible>true</sourceCompatible>
<semanticVersionLevel>PATCH</semanticVersionLevel>
</overrideCompatibilityChangeParameter>
<overrideCompatibilityChangeParameter>
<compatibilityChange>METHOD_DEFAULT_NOW_STATIC</compatibilityChange>
<binaryCompatible>true</binaryCompatible>
<sourceCompatible>true</sourceCompatible>
<semanticVersionLevel>PATCH</semanticVersionLevel>
</overrideCompatibilityChangeParameter>
</overrideCompatibilityChangeParameters>
<breakBuildOnBinaryIncompatibleModifications>true</breakBuildOnBinaryIncompatibleModifications>
<breakBuildOnSourceIncompatibleModifications>true</breakBuildOnSourceIncompatibleModifications>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,4 @@ public interface InterfaceWithStaticMethod {
public interface InterfaceWithDefaultMethod {

}

public interface InterfaceAbstractMethodToStatic {
void doSomething();
}

public static class ClassAbstractMethodToStatic implements InterfaceAbstractMethodToStatic {

@Override
public void doSomething() {
System.out.println("test");
}
}

public interface InterfaceDefaultMethodToStatic {
default void doSomething() {
System.out.println("Test");
}
}

public static class ClassDefaultMethodToStatic implements InterfaceDefaultMethodToStatic {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,4 @@ default void test() {

}
}

public interface InterfaceAbstractMethodToStatic {
static void doSomething() {

}
}

public static class ClassAbstractMethodToStatic implements InterfaceAbstractMethodToStatic {

public void doSomething() {
System.out.println("test");
}
}

public interface InterfaceDefaultMethodToStatic {
static void doSomething() {
System.out.println("Test");
}
}

public static class ClassDefaultMethodToStatic implements InterfaceDefaultMethodToStatic {

}
}
2 changes: 1 addition & 1 deletion japicmp-testbase/japicmp-test-vx-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<groupId>com.github.siom79.japicmp</groupId>
<artifactId>japicmp-test-v2</artifactId>
<version>${project.version}</version>
<scope>provided</scope> <!-- for compilation order -->
<scope>provided</scope>
</dependency>
</dependencies>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,7 @@ private void checkAbstractMethod(JApiClass jApiClass, Map<String, JApiClass> cla
}
JApiModifier<StaticModifier> staticModifier = method.getStaticModifier();
if (staticModifier.hasChangedFromTo(StaticModifier.NON_STATIC, StaticModifier.STATIC)) {
// changed from default to static
if (abstractModifier.getChangeStatus() == JApiChangeStatus.UNCHANGED && abstractModifier.getNewModifier().isPresent() && abstractModifier.getNewModifier().get() == AbstractModifier.NON_ABSTRACT) {
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_DEFAULT_NOW_STATIC);
} else {
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_NON_STATIC_IN_INTERFACE_NOW_STATIC);
}
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_NON_STATIC_IN_INTERFACE_NOW_STATIC);
} else if (staticModifier.hasChangedFromTo(StaticModifier.STATIC, StaticModifier.NON_STATIC)) {
addCompatibilityChange(method, JApiCompatibilityChange.METHOD_STATIC_IN_INTERFACE_NO_LONGER_STATIC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public enum JApiCompatibilityChange {
METHOD_ABSTRACT_ADDED_IN_IMPLEMENTED_INTERFACE(true, false, JApiSemanticVersionLevel.MINOR),
METHOD_DEFAULT_ADDED_IN_IMPLEMENTED_INTERFACE(true, true, JApiSemanticVersionLevel.MINOR),
METHOD_NEW_DEFAULT(true, true, JApiSemanticVersionLevel.MINOR),
METHOD_DEFAULT_NOW_STATIC(false, false, JApiSemanticVersionLevel.MAJOR),
METHOD_NEW_STATIC_ADDED_TO_INTERFACE(true, true, JApiSemanticVersionLevel.MINOR),
METHOD_MOVED_TO_SUPERCLASS(true, true, JApiSemanticVersionLevel.PATCH),
METHOD_ABSTRACT_NOW_DEFAULT(false, false, JApiSemanticVersionLevel.MAJOR),
Expand Down
63 changes: 31 additions & 32 deletions japicmp/src/test/java/japicmp/compat/CompatibilityChangesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,37 @@ public List<CtClass> createNewClasses(ClassPool classPool) throws Exception {
assertThat(jApiMethod.isSourceCompatible(), is(true));
}

@Test
public void testMethodNotStaticChangesToStaticInInterface() throws Exception {
JarArchiveComparatorOptions options = new JarArchiveComparatorOptions();
options.setIncludeSynthetic(true);
options.setAccessModifier(AccessModifier.PRIVATE);
List<JApiClass> jApiClasses = ClassesHelper.compareClasses(options, new ClassesHelper.ClassesGenerator() {
@Override
public List<CtClass> createOldClasses(ClassPool classPool) throws Exception {
CtClass ctClass = CtInterfaceBuilder.create().name("japicmp.Test").addToClassPool(classPool);
CtMethodBuilder.create().publicAccess().name("method").addToClass(ctClass);
return Collections.singletonList(ctClass);
}

@Override
public List<CtClass> createNewClasses(ClassPool classPool) throws Exception {
CtClass ctClass = CtInterfaceBuilder.create().name("japicmp.Test").addToClassPool(classPool);
CtMethodBuilder.create().publicAccess().staticAccess().name("method").addToClass(ctClass);
return Collections.singletonList(ctClass);
}
});
JApiClass jApiClass = getJApiClass(jApiClasses, "japicmp.Test");
assertThat(jApiClass.getChangeStatus(), is(JApiChangeStatus.MODIFIED));
assertThat(jApiClass.isBinaryCompatible(), is(true));
assertThat(jApiClass.isSourceCompatible(), is(true));
JApiMethod jApiMethod = getJApiMethod(jApiClass.getMethods(), "method");
assertThat(jApiMethod.getChangeStatus(), is(JApiChangeStatus.MODIFIED));
assertThat(jApiMethod.getCompatibilityChanges(), hasItem(JApiCompatibilityChange.METHOD_NON_STATIC_IN_INTERFACE_NOW_STATIC));
assertThat(jApiMethod.isBinaryCompatible(), is(true));
assertThat(jApiMethod.isSourceCompatible(), is(true));
}

@Test
public void testMethodStaticChangesToNotStaticInInterface() throws Exception {
JarArchiveComparatorOptions options = new JarArchiveComparatorOptions();
Expand Down Expand Up @@ -1623,38 +1654,6 @@ public List<CtClass> createNewClasses(ClassPool classPool) throws Exception {
assertThat(jApiMethod.getCompatibilityChanges(), not(hasItem(JApiCompatibilityChange.METHOD_ADDED_TO_INTERFACE)));
}

@Test
public void testInterfaceMethodDefaultToStatic() throws Exception {
JarArchiveComparatorOptions options = new JarArchiveComparatorOptions();
List<JApiClass> jApiClasses = ClassesHelper.compareClasses(options, new ClassesHelper.ClassesGenerator() {
@Override
public List<CtClass> createOldClasses(ClassPool classPool) throws Exception {
CtClass ctInterface = CtInterfaceBuilder.create().name("japicmp.Interface").addToClassPool(classPool);
CtMethodBuilder.create().publicAccess().name("defaultMethodToStatic").addToClass(ctInterface);
CtClass ctClass = CtClassBuilder.create().name("japicmp.Test").implementsInterface(ctInterface).addToClassPool(classPool);
return Arrays.asList(ctClass, ctInterface);
}

@Override
public List<CtClass> createNewClasses(ClassPool classPool) throws Exception {
CtClass ctInterface = CtInterfaceBuilder.create().name("japicmp.Interface").addToClassPool(classPool);
CtMethodBuilder.create().publicAccess().staticAccess().name("defaultMethodToStatic").addToClass(ctInterface);
CtClass ctClass = CtClassBuilder.create().name("japicmp.Test").implementsInterface(ctInterface).addToClassPool(classPool);
return Arrays.asList(ctClass, ctInterface);
}
});
JApiClass jApiClass = getJApiClass(jApiClasses, "japicmp.Test");
assertThat(jApiClass.isBinaryCompatible(), is(true));
assertThat(jApiClass.isSourceCompatible(), is(true));
jApiClass = getJApiClass(jApiClasses, "japicmp.Interface");
assertThat(jApiClass.isBinaryCompatible(), is(false));
assertThat(jApiClass.isSourceCompatible(), is(false));
JApiMethod jApiMethod = getJApiMethod(jApiClass.getMethods(), "defaultMethodToStatic");
assertThat(jApiMethod.isBinaryCompatible(), is(false));
assertThat(jApiMethod.isSourceCompatible(), is(false));
assertThat(jApiMethod.getCompatibilityChanges(), hasItem(JApiCompatibilityChange.METHOD_DEFAULT_NOW_STATIC));
}

@Test
public void testInterfaceDefaultMethodOverriddenInSubInterface() throws Exception {
JarArchiveComparatorOptions options = new JarArchiveComparatorOptions();
Expand Down

0 comments on commit 9d3997b

Please sign in to comment.