diff --git a/japicmp/src/main/java/japicmp/compat/Test.java b/japicmp/src/main/java/japicmp/compat/Test.java deleted file mode 100644 index 617d20b2a..000000000 --- a/japicmp/src/main/java/japicmp/compat/Test.java +++ /dev/null @@ -1,6 +0,0 @@ -package japicmp.compat; - -import java.text.SimpleDateFormat; - -public class Test extends SimpleDateFormat { -} diff --git a/japicmp/src/test/java/japicmp/compat/CompatibilityChangesTest.java b/japicmp/src/test/java/japicmp/compat/CompatibilityChangesTest.java index aff6e1d3b..05847b2af 100755 --- a/japicmp/src/test/java/japicmp/compat/CompatibilityChangesTest.java +++ b/japicmp/src/test/java/japicmp/compat/CompatibilityChangesTest.java @@ -2196,4 +2196,32 @@ public List createNewClasses(ClassPool classPool) throws Exception { jApiMethod = getJApiMethod(jApiClass.getMethods(), "method"); assertThat(jApiMethod.getChangeStatus(), is(JApiChangeStatus.REMOVED)); } + + @Test + public void testPackagePrivateClassChangesToPublicClassWithMethodReturnTypeChangeIssue365() throws Exception { + JarArchiveComparatorOptions jarArchiveComparatorOptions = new JarArchiveComparatorOptions(); + jarArchiveComparatorOptions.setAccessModifier(AccessModifier.PRIVATE); + List jApiClasses = ClassesHelper.compareClasses(jarArchiveComparatorOptions, new ClassesHelper.ClassesGenerator() { + @Override + public List createOldClasses(ClassPool classPool) throws Exception { + CtClass ctInterfaceF = CtInterfaceBuilder.create().name("F").addToClassPool(classPool); + CtClass ctClassC = CtClassBuilder.create().name("C").protectedModifier().addToClassPool(classPool); + CtMethodBuilder.create().publicAccess().staticAccess().name("M").returnType(ctInterfaceF).addToClass(ctClassC); + return Arrays.asList(ctInterfaceF, ctClassC); + } + + @Override + public List createNewClasses(ClassPool classPool) throws Exception { + CtClass ctInterfaceF = CtInterfaceBuilder.create().name("F").addToClassPool(classPool); + CtClass ctClassFImpl = CtClassBuilder.create().name("FImpl").implementsInterface(ctInterfaceF).addToClassPool(classPool); + CtClass ctClassC = CtClassBuilder.create().name("C").protectedModifier().addToClassPool(classPool); + CtMethodBuilder.create().publicAccess().staticAccess().name("M").returnType(ctClassFImpl).addToClass(ctClassC); + return Arrays.asList(ctInterfaceF, ctClassC); + } + }); + JApiClass jApiClass = getJApiClass(jApiClasses, "C"); + JApiMethod jApiMethod = getJApiMethod(jApiClass.getMethods(), "M"); + assertThat(jApiMethod.getChangeStatus(), is(JApiChangeStatus.MODIFIED)); + assertThat(jApiMethod.getCompatibilityChanges(), hasItem(JApiCompatibilityChange.METHOD_RETURN_TYPE_CHANGED)); + } } diff --git a/japicmp/src/test/java/japicmp/util/CtClassBuilder.java b/japicmp/src/test/java/japicmp/util/CtClassBuilder.java index c007fb2a0..a9e2d947a 100644 --- a/japicmp/src/test/java/japicmp/util/CtClassBuilder.java +++ b/japicmp/src/test/java/japicmp/util/CtClassBuilder.java @@ -52,6 +52,13 @@ public CtClassBuilder privateModifier() { return this; } + public CtClassBuilder protectedModifier() { + this.modifier = this.modifier & ~Modifier.PUBLIC; + this.modifier = this.modifier & ~Modifier.PRIVATE; + this.modifier |= Modifier.PROTECTED; + return this; + } + public CtClassBuilder enumModifier() { this.modifier = this.modifier | Modifier.ENUM; return this; diff --git a/src/site/markdown/MavenPlugin.md b/src/site/markdown/MavenPlugin.md index 3e1d0c87e..7ad81ffb1 100644 --- a/src/site/markdown/MavenPlugin.md +++ b/src/site/markdown/MavenPlugin.md @@ -217,45 +217,45 @@ The elements <oldVersion> and <newVersion> elements let you specify support either a <dependency> or a <file> element. If necessary you can select the artifact by providing a <classifier> element inside the <dependency> element. Through the <parameter> element you can provide the following options: -| Parameter | Optional | Default | Description | -|-----------|----------|---------|-------------| -| breakBuildOnModifications | true | false | If set to true, the build breaks in case a modification has been detected.| -| breakBuildOnBinaryIncompatibleModifications | true | false | If set to true, the build breaks in case a binary incompatible modification has been detected.| -| breakBuildOnSourceIncompatibleModifications | true | false | If set to true, the build breaks in case a source incompatible modification has been detected.| -| breakBuildBasedOnSemanticVersioning | true | false | If set to true, the plugin analyzes the versions of the old and new archives and decides based on these versions if binary compatible or incompatible changes are allowed or not. This option expects versions in the form Major.Minor.Patch (e.g. 1.2.3 or 1.2.3-SNAPSHOT).| -| breakBuildBasedOnSemanticVersioningForMajorVersionZero | true | false | If set to true, the plugin will apply the option breakBuildBasedOnSemanticVersioning also for projects with major version zero (which is not required by the Semantic Versioning Specification).| -| breakBuildIfCausedByExclusion | true | true | If set to false, the plugin won't break the build if the incompatible change was caused by an excluded class (e.g. excluded interface removed from not excluded class).| -| overrideCompatibilityChangeParameters | true | n.a. | Can be used to override default values for binary and source compatibility checks.| -| onlyBinaryIncompatible | true | false | If set to true, only binary incompatible changes are reported.| -| onlyModified | true | false | Outputs only modified classes/methods. If not set to true, all classes and methods are printed.| -| includeSynthetic | true | false | If set to true, changes for synthetic classes and class members are tracked.| -| noAnnotations | true | false | Setting this option to true disables the evaluation of annotations completely.| -| reportOnlyFilename | true | false | If set to true, report will include only the artifact filename, not the complete artifact file path.| -| ignoreMissingClasses | true | false | If set to true, superclasses and interfaces that cannot be resolved are ignored. Pleases note that in this case the results for the affected classes may not be accurate.| -| ignoreMissingClassesByRegularExpressions | true | n.a. | List of regular expressions for superclasses and interfaces that cannot be resolved and that should be ignored. In contrast to the option ignoreMissingClasses, which ignores all missing classes, this options allows a fine-grained selection.| -| accessModifier | true | protected | Sets the access modifier level (public, package, protected, private).| -| includes | true | n.a. | List of package, classes, methods and field that should be included. The syntax is similar to the one used for javadoc references. Annotations can also be used for filtering, just let the fully qualified name start with @.| -| excludes | true | n.a. | List of package, classes, methods and field that should be excluded. The syntax is similar to the one used for javadoc references. Annotations can also be used for filtering, just let the fully qualified name start with @.| -| includeExclusively | true | false | Include only packages specified in the "includes" parameter, exclude their sub-packages.| -| excludeExclusively | true | false | Exclude only packages specified in the "excludes" parameter, include their sub-packages.| -| htmlStylesheet | true | n.a. | Path to an individual CSS stylesheet for the HTML report.| -| htmlTitle | true | n.a. | A title for the HTML report (optional).| -| skipPomModules | true | true | Setting this parameter to false (default: true) will not skip execution in modules with packaging type pom.| -| skip | true | false | Setting this parameter to true will skip execution of the plugin.| -| ignoreNonResolvableArtifacts | true | false | Set this to true in order to ignore artifacts that cannot be resolved, i.e. the build does not break in case a dependency cannot be resolved to a file.| -| ignoreMissingOptionalDependency | true | false | Ignore missing optional dependencies.| -| ignoreMissingOldVersion | true | false | If set to true, not resolvable artifacts for the old version do not break the build.| -| ignoreMissingNewVersion | true | false | If set to true, not resolvable artifacts for the new version do not break the build.| -| packagingSupported | true | n.a. | List all packaging type for which the plugin should be executed. Helpful if you define the plugin in a root pom.| -| postAnalysisScript | true | n.a. | A [Groovy](http|//www.groovy-lang.org/) script that gets invoked after analysis is completed and before the output is written. This way it can be used to filter the output or break the build on specific conditions. It can be an absolute path or a relative path of a file within the classpath.| -| skipXmlReport | true | false | If set to true, no XML report will be generated.| -| skipHtmlReport | true | false | If set to true, no HTML report will be generated.| -| skipDiffReport | true | false | If set to true, no diff report will be generated.| -| oldVersionPattern | true | n.a. | If <oldVersion> is not used, the old version compared against must match this regular expression.| -| includeModules | true | n.a. | List of regular expression that specify if an artifact should be excluded based on its artifact id.| -| excludeModules | true | n.a. | List of regular expression that specify if an artifact should be included based on its artifact id.| -| reportLinkName | true | japicmp | Name of the Site Report. Defaults to 'japicmp'. You must specify different names when using a ReportSet.| -| includeSnapshots | true | false | If <oldVersion> is not used, this determines whether to include SNAPSHOT versions when resolving the version to compare. | +| Parameter | Optional | Default | Description | +|-----------|----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| breakBuildOnModifications | true | false | If set to true, the build breaks in case a modification has been detected. | +| breakBuildOnBinaryIncompatibleModifications | true | false | If set to true, the build breaks in case a binary incompatible modification has been detected. | +| breakBuildOnSourceIncompatibleModifications | true | false | If set to true, the build breaks in case a source incompatible modification has been detected. | +| breakBuildBasedOnSemanticVersioning | true | false | If set to true, the plugin analyzes the versions of the old and new archives and decides based on these versions if binary compatible or incompatible changes are allowed or not. This option expects versions in the form Major.Minor.Patch (e.g. 1.2.3 or 1.2.3-SNAPSHOT). | +| breakBuildBasedOnSemanticVersioningForMajorVersionZero | true | false | If set to true, the plugin will apply the option breakBuildBasedOnSemanticVersioning also for projects with major version zero (which is not required by the Semantic Versioning Specification). | +| breakBuildIfCausedByExclusion | true | true | If set to false, the plugin won't break the build if the incompatible change was caused by an excluded class (e.g. excluded interface removed from not excluded class). | +| overrideCompatibilityChangeParameters | true | n.a. | Can be used to override default values for binary and source compatibility checks. | +| onlyBinaryIncompatible | true | false | If set to true, only binary incompatible changes are reported. | +| onlyModified | true | false | Outputs only modified classes/methods. If not set to true, all classes and methods are printed. | +| includeSynthetic | true | false | If set to true, changes for synthetic classes and class members are tracked. | +| noAnnotations | true | false | Setting this option to true disables the evaluation of annotations completely. | +| reportOnlyFilename | true | false | If set to true, report will include only the artifact filename, not the complete artifact file path. | +| ignoreMissingClasses | true | false | If set to true, superclasses and interfaces that cannot be resolved are ignored. Pleases note that in this case the results for the affected classes may not be accurate. | +| ignoreMissingClassesByRegularExpressions | true | n.a. | List of regular expressions for superclasses and interfaces that cannot be resolved and that should be ignored. In contrast to the option ignoreMissingClasses, which ignores all missing classes, this options allows a fine-grained selection. | +| accessModifier | true | protected | Sets the access modifier level (public, protected, package_protected, private). | +| includes | true | n.a. | List of package, classes, methods and field that should be included. The syntax is similar to the one used for javadoc references. Annotations can also be used for filtering, just let the fully qualified name start with @. | +| excludes | true | n.a. | List of package, classes, methods and field that should be excluded. The syntax is similar to the one used for javadoc references. Annotations can also be used for filtering, just let the fully qualified name start with @. | +| includeExclusively | true | false | Include only packages specified in the "includes" parameter, exclude their sub-packages. | +| excludeExclusively | true | false | Exclude only packages specified in the "excludes" parameter, include their sub-packages. | +| htmlStylesheet | true | n.a. | Path to an individual CSS stylesheet for the HTML report. | +| htmlTitle | true | n.a. | A title for the HTML report (optional). | +| skipPomModules | true | true | Setting this parameter to false (default: true) will not skip execution in modules with packaging type pom. | +| skip | true | false | Setting this parameter to true will skip execution of the plugin. | +| ignoreNonResolvableArtifacts | true | false | Set this to true in order to ignore artifacts that cannot be resolved, i.e. the build does not break in case a dependency cannot be resolved to a file. | +| ignoreMissingOptionalDependency | true | false | Ignore missing optional dependencies. | +| ignoreMissingOldVersion | true | false | If set to true, not resolvable artifacts for the old version do not break the build. | +| ignoreMissingNewVersion | true | false | If set to true, not resolvable artifacts for the new version do not break the build. | +| packagingSupported | true | n.a. | List all packaging type for which the plugin should be executed. Helpful if you define the plugin in a root pom. | +| postAnalysisScript | true | n.a. | A [Groovy](http |//www.groovy-lang.org/) script that gets invoked after analysis is completed and before the output is written. This way it can be used to filter the output or break the build on specific conditions. It can be an absolute path or a relative path of a file within the classpath.| +| skipXmlReport | true | false | If set to true, no XML report will be generated. | +| skipHtmlReport | true | false | If set to true, no HTML report will be generated. | +| skipDiffReport | true | false | If set to true, no diff report will be generated. | +| oldVersionPattern | true | n.a. | If <oldVersion> is not used, the old version compared against must match this regular expression. | +| includeModules | true | n.a. | List of regular expression that specify if an artifact should be excluded based on its artifact id. | +| excludeModules | true | n.a. | List of regular expression that specify if an artifact should be included based on its artifact id. | +| reportLinkName | true | japicmp | Name of the Site Report. Defaults to 'japicmp'. You must specify different names when using a ReportSet. | +| includeSnapshots | true | false | If <oldVersion> is not used, this determines whether to include SNAPSHOT versions when resolving the version to compare. | The parameter overrideCompatibilityChangeParameters allows you to override the default values for binary and source compatibility as well as the semantic version level for each check. This allows you to customize the following verifications: