diff --git a/.github/workflows/cibuild.yml b/.github/workflows/cibuild.yml index eeeb4194..8b4c0396 100644 --- a/.github/workflows/cibuild.yml +++ b/.github/workflows/cibuild.yml @@ -49,8 +49,7 @@ jobs: os: - 'ubuntu-latest' java: - - '8' - - '11' + - '21' include: - os: 'ubuntu-latest' java: '17' diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar index bf82ff01..7967f30d 100644 Binary files a/.mvn/wrapper/maven-wrapper.jar and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index ca5ab4ba..9548abd8 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -6,7 +6,7 @@ # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # -# https://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an @@ -14,5 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar +wrapperVersion=3.3.2 +distributionType=bin +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/.settings/org.eclipse.jdt.core.prefs b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/.settings/org.eclipse.jdt.core.prefs index e8532c39..c772cad8 100644 --- a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/.settings/org.eclipse.jdt.core.prefs +++ b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -150,7 +150,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME diff --git a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerAnalyzerPlugin.java b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerAnalyzerPlugin.java index acbb88ac..6adec932 100644 --- a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerAnalyzerPlugin.java +++ b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerAnalyzerPlugin.java @@ -21,9 +21,9 @@ @ExternalPlugin(name = "Transformer", objectClass = AnalyzerPlugin.class) public class TransformerAnalyzerPlugin extends BaseTransformerPlugin implements AnalyzerPlugin { public TransformerAnalyzerPlugin() { - /** - * We want to run before other AnalyzerPlugins so they will operate on - * the transformed classes and resources. + /* + We want to run before other AnalyzerPlugins so they will operate on + the transformed classes and resources. */ super(-10_000); } diff --git a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerVerifierPlugin.java b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerVerifierPlugin.java index fd33df59..29287bb4 100644 --- a/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerVerifierPlugin.java +++ b/bnd-plugins/org.eclipse.transformer.bnd.analyzer/src/main/java/org/eclipse/transformer/bnd/analyzer/TransformerVerifierPlugin.java @@ -21,9 +21,9 @@ @ExternalPlugin(name = "Transformer", objectClass = VerifierPlugin.class) public class TransformerVerifierPlugin extends BaseTransformerPlugin implements VerifierPlugin { public TransformerVerifierPlugin() { - /** - * We want to run after other VerifierPlugins so we will operate on the - * final classes and resources. + /* + We want to run after other VerifierPlugins so we will operate on the + final classes and resources. */ super(10_000); } diff --git a/maven-plugins/transformer-maven-plugin/.settings/org.eclipse.jdt.core.prefs b/maven-plugins/transformer-maven-plugin/.settings/org.eclipse.jdt.core.prefs index e8532c39..c772cad8 100644 --- a/maven-plugins/transformer-maven-plugin/.settings/org.eclipse.jdt.core.prefs +++ b/maven-plugins/transformer-maven-plugin/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -150,7 +150,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME diff --git a/maven-plugins/transformer-maven-plugin/README.md b/maven-plugins/transformer-maven-plugin/README.md index 35765ad6..99be8683 100644 --- a/maven-plugins/transformer-maven-plugin/README.md +++ b/maven-plugins/transformer-maven-plugin/README.md @@ -8,8 +8,6 @@ This plugin contains the following goals: - [`transform`](#transform-goal) - [`help`](#help-goal) -__Note__: if you are using Java 21 or later see [Using Java 21 or later](#java-21-or-later). - ## `jar` Goal The `jar` goal operates at the JAR file level and transforms the specified input artifact into a project artifact. @@ -253,17 +251,3 @@ It is therefore necessary to configure the `maven-jar-plugin` as follows: The `help` goal displays help about the goals of the plugin. Call `mvn transformer:help -Ddetail=true -Dgoal=` to display configuration details for the specified goal. - -## Java 21 or later - -If you are using Java 21 or later you will need to configure the Maven plugin to use a specific version of the `biz.aQute.bndlib` dependency. - -For example: - -```xml - - biz.aQute.bnd - biz.aQute.bndlib - 7.0.0 - -``` diff --git a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/AbstractTransformerMojo.java b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/AbstractTransformerMojo.java index 63bb3fee..9f561b30 100644 --- a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/AbstractTransformerMojo.java +++ b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/AbstractTransformerMojo.java @@ -79,7 +79,7 @@ public boolean skip() { // Exit without generating anything if this project is not a known // packaging type. Probably it's just a parent project. if (!getPackagingTypes().contains(getProject().getPackaging())) { - getLogger().debug("skip project with packaging=" + getProject().getPackaging()); + getLogger().debug("skip project with packaging={}", getProject().getPackaging()); return true; } diff --git a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerJarMojo.java b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerJarMojo.java index 9cd9c3ad..cb3cfae3 100644 --- a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerJarMojo.java +++ b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerJarMojo.java @@ -290,16 +290,16 @@ private TransformerArtifact prepareArtifactDescription(TransformerArtifact artif List firstPass = dependencies.stream() .filter(dependency -> Objects.equals(artifactDescription.getGroupId(), dependency.getGroupId()) && Objects.equals(artifactDescription.getArtifactId(), dependency.getArtifactId())) - .collect(toList()); + .toList(); Optional matchingDependency = firstPass.stream() .filter(dependency -> Objects.equals(artifactDescription.getClassifier(), dependency.getClassifier()) && Objects.equals(artifactDescription.getType(), dependency.getType())) .findFirst(); - if (!matchingDependency.isPresent()) { + if (matchingDependency.isEmpty()) { matchingDependency = firstPass.stream() .findFirst(); - if (!matchingDependency.isPresent()) { + if (matchingDependency.isEmpty()) { throw new MojoExecutionException(String.format( "No version found for artifact %s:%s in project, dependencies, or dependency management", artifactDescription.getGroupId(), artifactDescription.getArtifactId())); diff --git a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMavenLifecycleParticipant.java b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMavenLifecycleParticipant.java index d6baa2e0..63a48a56 100644 --- a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMavenLifecycleParticipant.java +++ b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMavenLifecycleParticipant.java @@ -178,11 +178,11 @@ public static String extractClassifier(PluginExecution execution) { Optional rootConfiguration = Optional.ofNullable((Xpp3Dom) execution.getConfiguration()); Optional classifierConfiguration = rootConfiguration .map(configuration -> configuration.getChild("classifier")); - if (!classifierConfiguration.isPresent()) { + if (classifierConfiguration.isEmpty()) { classifierConfiguration = rootConfiguration.map(configuration -> configuration.getChild("artifact")) .map(configuration -> configuration.getChild("classifier")); } - if (!classifierConfiguration.isPresent()) { + if (classifierConfiguration.isEmpty()) { return defaultClassifier(execution); } diff --git a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMojoOptions.java b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMojoOptions.java index ee09d92b..a6bfe2bf 100644 --- a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMojoOptions.java +++ b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerMojoOptions.java @@ -63,59 +63,29 @@ private static List condition(List values) { @Override public List getOptionValues(AppOption option) { - List values; - switch (option) { - case RULES_BUNDLES : - values = rules.getBundles(); - break; - case RULES_DIRECT : - values = rules.getDirects(); - break; - case RULES_IMMEDIATE_DATA : - values = rules.getImmediates(); - break; - case RULES_MASTER_TEXT : - values = rules.getTexts(); - break; - case RULES_PER_CLASS_CONSTANT : - values = rules.getPerClassConstants(); - break; - case RULES_RENAMES : - values = rules.getRenames(); - break; - case RULES_SELECTIONS : - values = rules.getSelections(); - break; - case RULES_VERSIONS : - values = rules.getVersions(); - break; - default : - values = null; - break; - } + List values = switch (option) { + case RULES_BUNDLES -> rules.getBundles(); + case RULES_DIRECT -> rules.getDirects(); + case RULES_IMMEDIATE_DATA -> rules.getImmediates(); + case RULES_MASTER_TEXT -> rules.getTexts(); + case RULES_PER_CLASS_CONSTANT -> rules.getPerClassConstants(); + case RULES_RENAMES -> rules.getRenames(); + case RULES_SELECTIONS -> rules.getSelections(); + case RULES_VERSIONS -> rules.getVersions(); + default -> null; + }; return condition(values); } @Override public boolean hasOption(AppOption option) { - boolean has; - switch (option) { - case OVERWRITE : - has = rules.isOverwrite(); - break; - case INVERT : - has = rules.isInvert(); - break; - case WIDEN_ARCHIVE_NESTING : - has = rules.isWiden(); - break; - case STRIP_SIGNATURES : - has = rules.isStripSignatures(); - break; - default : - has = TransformOptions.super.hasOption(option); - break; - } + boolean has = switch (option) { + case OVERWRITE -> rules.isOverwrite(); + case INVERT -> rules.isInvert(); + case WIDEN_ARCHIVE_NESTING -> rules.isWiden(); + case STRIP_SIGNATURES -> rules.isStripSignatures(); + default -> TransformOptions.super.hasOption(option); + }; return has; } diff --git a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerRunMojo.java b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerRunMojo.java index 6ae14943..87db741d 100644 --- a/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerRunMojo.java +++ b/maven-plugins/transformer-maven-plugin/src/main/java/org/eclipse/transformer/maven/TransformerRunMojo.java @@ -119,7 +119,7 @@ public void execute() throws MojoFailureException, MojoExecutionException { */ public void transform(final Artifact sourceArtifact) throws MojoFailureException, MojoExecutionException { final String sourceClassifier = sourceArtifact.getClassifier(); - final String targetClassifier = (sourceClassifier == null || sourceClassifier.length() == 0) ? this.classifier + final String targetClassifier = (sourceClassifier == null || sourceClassifier.isEmpty()) ? this.classifier : sourceClassifier + "-" + this.classifier; final File targetFile = new File(outputDirectory, sourceArtifact.getArtifactId() + "-" + targetClassifier + "-" @@ -129,36 +129,25 @@ public void transform(final Artifact sourceArtifact) throws MojoFailureException final Function ruleLoader = JakartaTransform.getRuleLoader(); @Override public boolean hasOption(AppOption option) { - switch (option) { - case OVERWRITE : - return overwrite; - case INVERT : - return invert; - case STRIP_SIGNATURES: - return stripSignatures; - default : - return TransformOptions.super.hasOption(option); - } + return switch (option) { + case OVERWRITE -> overwrite; + case INVERT -> invert; + case STRIP_SIGNATURES -> stripSignatures; + default -> TransformOptions.super.hasOption(option); + }; } @Override public String getOptionValue(AppOption option) { - switch (option) { - case RULES_RENAMES : - return emptyAsNull(rulesRenamesUri); - case RULES_VERSIONS : - return emptyAsNull(rulesVersionUri); - case RULES_BUNDLES : - return emptyAsNull(rulesBundlesUri); - case RULES_DIRECT : - return emptyAsNull(rulesDirectUri); - case RULES_MASTER_TEXT : - return emptyAsNull(rulesXmlsUri); - case RULES_PER_CLASS_CONSTANT : - return emptyAsNull(rulesPerClassConstantUri); - default : - return null; - } + return switch (option) { + case RULES_RENAMES -> emptyAsNull(rulesRenamesUri); + case RULES_VERSIONS -> emptyAsNull(rulesVersionUri); + case RULES_BUNDLES -> emptyAsNull(rulesBundlesUri); + case RULES_DIRECT -> emptyAsNull(rulesDirectUri); + case RULES_MASTER_TEXT -> emptyAsNull(rulesXmlsUri); + case RULES_PER_CLASS_CONSTANT -> emptyAsNull(rulesPerClassConstantUri); + default -> null; + }; } @Override diff --git a/maven-plugins/transformer-maven-plugin/src/test/java/org/eclipse/transformer/maven/TransformerRunMojoTest.java b/maven-plugins/transformer-maven-plugin/src/test/java/org/eclipse/transformer/maven/TransformerRunMojoTest.java index 443c9eb3..5415c7c5 100644 --- a/maven-plugins/transformer-maven-plugin/src/test/java/org/eclipse/transformer/maven/TransformerRunMojoTest.java +++ b/maven-plugins/transformer-maven-plugin/src/test/java/org/eclipse/transformer/maven/TransformerRunMojoTest.java @@ -146,7 +146,7 @@ public void testMultipleArtifactTransformerPlugin() throws Exception { .equals("zip") && a.getArtifactId() .equals("simple-service"))) - .map(a -> a.getClassifier()) + .map(Artifact::getClassifier) .collect(Collectors.toSet()); assertEquals(6, mavenProject.getAttachedArtifacts() @@ -260,7 +260,7 @@ private static File createService(String packaging, File targetDirectory) throws final File tempFile = File.createTempFile("service", "." + packaging); tempFile.delete(); - final Archive archive; + final Archive archive; if (packaging.equals("jar")) { archive = ShrinkWrap.create(JavaArchive.class, "service." + packaging) .addClass(EchoService.class); diff --git a/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-artifact/pom.xml b/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-artifact/pom.xml index 085fc0bd..90008cdf 100644 --- a/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-artifact/pom.xml +++ b/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-artifact/pom.xml @@ -23,8 +23,7 @@ UTF-8 - 1.8 - 1.8 + 17 diff --git a/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-jar-artifact/pom.xml b/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-jar-artifact/pom.xml index 5b86a207..d50f7b17 100644 --- a/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-jar-artifact/pom.xml +++ b/maven-plugins/transformer-maven-plugin/src/test/projects/transform-build-jar-artifact/pom.xml @@ -23,8 +23,7 @@ UTF-8 - 1.8 - 1.8 + 17 @@ -57,9 +56,6 @@ maven-jar-plugin - - false - diff --git a/mvnw b/mvnw index b7f06462..5e9618ca 100755 --- a/mvnw +++ b/mvnw @@ -19,7 +19,7 @@ # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.1.1 +# Apache Maven Wrapper startup batch script, version 3.3.2 # # Required ENV vars: # ------------------ @@ -33,252 +33,297 @@ # MAVEN_SKIP_RC - flag to disable loading of mavenrc files # ---------------------------------------------------------------------------- -if [ -z "$MAVEN_SKIP_RC" ] ; then +if [ -z "$MAVEN_SKIP_RC" ]; then - if [ -f /usr/local/etc/mavenrc ] ; then + if [ -f /usr/local/etc/mavenrc ]; then . /usr/local/etc/mavenrc fi - if [ -f /etc/mavenrc ] ; then + if [ -f /etc/mavenrc ]; then . /etc/mavenrc fi - if [ -f "$HOME/.mavenrc" ] ; then + if [ -f "$HOME/.mavenrc" ]; then . "$HOME/.mavenrc" fi fi # OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; +cygwin=false +darwin=false mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="`/usr/libexec/java_home`"; export JAVA_HOME - else - JAVA_HOME="/Library/Java/Home"; export JAVA_HOME - fi +case "$(uname)" in +CYGWIN*) cygwin=true ;; +MINGW*) mingw=true ;; +Darwin*) + darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + JAVA_HOME="$(/usr/libexec/java_home)" + export JAVA_HOME + else + JAVA_HOME="/Library/Java/Home" + export JAVA_HOME fi - ;; + fi + ;; esac -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` +if [ -z "$JAVA_HOME" ]; then + if [ -r /etc/gentoo-release ]; then + JAVA_HOME=$(java-config --jre-home) fi fi # For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +if $cygwin; then + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") fi # For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +if $mingw; then + [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ + && JAVA_HOME="$( + cd "$JAVA_HOME" || ( + echo "cannot cd into $JAVA_HOME." >&2 + exit 1 + ) + pwd + )" fi if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + javaExecutable="$(which javac)" + if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + readLink=$(which readlink) + if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then + if $darwin; then + javaHome="$(dirname "$javaExecutable")" + javaExecutable="$(cd "$javaHome" && pwd -P)/javac" else - javaExecutable="`readlink -f \"$javaExecutable\"`" + javaExecutable="$(readlink -f "$javaExecutable")" fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` + javaHome="$(dirname "$javaExecutable")" + javaHome=$(expr "$javaHome" : '\(.*\)/bin') JAVA_HOME="$javaHome" export JAVA_HOME fi fi fi -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +if [ -z "$JAVACMD" ]; then + if [ -n "$JAVA_HOME" ]; then + if [ -x "$JAVA_HOME/jre/sh/java" ]; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi else - JAVACMD="`\\unset -f command; \\command -v java`" + JAVACMD="$( + \unset -f command 2>/dev/null + \command -v java + )" fi fi -if [ ! -x "$JAVACMD" ] ; then +if [ ! -x "$JAVACMD" ]; then echo "Error: JAVA_HOME is not defined correctly." >&2 echo " We cannot execute $JAVACMD" >&2 exit 1 fi -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." +if [ -z "$JAVA_HOME" ]; then + echo "Warning: JAVA_HOME environment variable is not set." >&2 fi # traverses directory structure from process work directory to filesystem root # first directory with .mvn subdirectory is considered project base directory find_maven_basedir() { - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" + if [ -z "$1" ]; then + echo "Path not specified to find_maven_basedir" >&2 return 1 fi basedir="$1" wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then + while [ "$wdir" != '/' ]; do + if [ -d "$wdir"/.mvn ]; then basedir=$wdir break fi # workaround for JBEAP-8937 (on Solaris 10/Sparc) if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` + wdir=$( + cd "$wdir/.." || exit 1 + pwd + ) fi # end of workaround done - printf '%s' "$(cd "$basedir"; pwd)" + printf '%s' "$( + cd "$basedir" || exit 1 + pwd + )" } # concatenates all lines of a file concat_lines() { if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" + # Remove \r in case we run on Windows within Git Bash + # and check out the repository with auto CRLF management + # enabled. Otherwise, we may read lines that are delimited with + # \r\n and produce $'-Xarg\r' rather than -Xarg due to word + # splitting rules. + tr -s '\r\n' ' ' <"$1" fi } -BASE_DIR=$(find_maven_basedir "$(dirname $0)") +log() { + if [ "$MVNW_VERBOSE" = true ]; then + printf '%s\n' "$1" + fi +} + +BASE_DIR=$(find_maven_basedir "$(dirname "$0")") if [ -z "$BASE_DIR" ]; then - exit 1; + exit 1 fi -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi +MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +export MAVEN_PROJECTBASEDIR +log "$MAVEN_PROJECTBASEDIR" ########################################################################################## # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central # This allows using the maven wrapper in projects that prohibit checking in binary data. ########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi +wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" +if [ -r "$wrapperJarPath" ]; then + log "Found $wrapperJarPath" else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + log "Couldn't find $wrapperJarPath, downloading it ..." + + if [ -n "$MVNW_REPOURL" ]; then + wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" + else + wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" + fi + while IFS="=" read -r key value; do + # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) + safeValue=$(echo "$value" | tr -d '\r') + case "$key" in wrapperUrl) + wrapperUrl="$safeValue" + break + ;; + esac + done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" + log "Downloading from: $wrapperUrl" + + if $cygwin; then + wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") + fi + + if command -v wget >/dev/null; then + log "Found wget ... using wget" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) wrapperUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $wrapperUrl" + elif command -v curl >/dev/null; then + log "Found curl ... using curl" + [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" + else + curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + else + log "Falling back to using Java to download" + javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" + javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" + # For Cygwin, switch paths to Windows format before running javac if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + javaSource=$(cygpath --path --windows "$javaSource") + javaClass=$(cygpath --path --windows "$javaClass") fi - - if command -v wget > /dev/null; then - QUIET="--quiet" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - QUIET="" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" - else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" - fi - [ $? -eq 0 ] || rm -f "$wrapperJarPath" - elif command -v curl > /dev/null; then - QUIET="--silent" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - QUIET="" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L - else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L - fi - [ $? -eq 0 ] || rm -f "$wrapperJarPath" - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaSource="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaSource=`cygpath --path --windows "$javaSource"` - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaSource") - fi - if [ -e "$javaClass" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi + if [ -e "$javaSource" ]; then + if [ ! -e "$javaClass" ]; then + log " - Compiling MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/javac" "$javaSource") + fi + if [ -e "$javaClass" ]; then + log " - Running MavenWrapperDownloader.java ..." + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" + fi fi + fi fi ########################################################################################## # End of extension ########################################################################################## +# If specified, validate the SHA-256 sum of the Maven wrapper jar file +wrapperSha256Sum="" +while IFS="=" read -r key value; do + case "$key" in wrapperSha256Sum) + wrapperSha256Sum=$value + break + ;; + esac +done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" +if [ -n "$wrapperSha256Sum" ]; then + wrapperSha256Result=false + if command -v sha256sum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then + wrapperSha256Result=true + fi + elif command -v shasum >/dev/null; then + if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then + wrapperSha256Result=true + fi + else + echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 + echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 + exit 1 + fi + if [ $wrapperSha256Result = false ]; then + echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 + echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 + echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 + exit 1 + fi +fi + MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" # For Cygwin, switch paths to Windows format before running java if $cygwin; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` + [ -n "$JAVA_HOME" ] \ + && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") + [ -n "$CLASSPATH" ] \ + && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") + [ -n "$MAVEN_PROJECTBASEDIR" ] \ + && MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") fi # Provide a "standardized" way to retrieve the CLI args that will # work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*" export MAVEN_CMD_LINE_ARGS WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain +# shellcheck disable=SC2086 # safe args exec "$JAVACMD" \ $MAVEN_OPTS \ $MAVEN_DEBUG_OPTS \ diff --git a/mvnw.cmd b/mvnw.cmd index cba1f040..1204076a 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -18,7 +18,7 @@ @REM ---------------------------------------------------------------------------- @REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.1.1 +@REM Apache Maven Wrapper startup batch script, version 3.3.2 @REM @REM Required ENV vars: @REM JAVA_HOME - location of a JDK home dir @@ -59,22 +59,22 @@ set ERROR_CODE=0 @REM ==== START VALIDATION ==== if not "%JAVA_HOME%" == "" goto OkJHome -echo. +echo. >&2 echo Error: JAVA_HOME not found in your environment. >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 -echo. +echo. >&2 goto error :OkJHome if exist "%JAVA_HOME%\bin\java.exe" goto init -echo. +echo. >&2 echo Error: JAVA_HOME is set to an invalid directory. >&2 echo JAVA_HOME = "%JAVA_HOME%" >&2 echo Please set the JAVA_HOME variable in your environment to match the >&2 echo location of your Java installation. >&2 -echo. +echo. >&2 goto error @REM ==== END VALIDATION ==== @@ -119,7 +119,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" +set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B @@ -133,7 +133,7 @@ if exist %WRAPPER_JAR% ( ) ) else ( if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar" + SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" ) if "%MVNW_VERBOSE%" == "true" ( echo Couldn't find %WRAPPER_JAR%, downloading it ... @@ -153,6 +153,25 @@ if exist %WRAPPER_JAR% ( ) @REM End of extension +@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file +SET WRAPPER_SHA_256_SUM="" +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B +) +IF NOT %WRAPPER_SHA_256_SUM%=="" ( + powershell -Command "&{"^ + "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ + "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ + "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ + " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ + " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ + " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ + " exit 1;"^ + "}"^ + "}" + if ERRORLEVEL 1 goto error +) + @REM Provide a "standardized" way to retrieve the CLI args that will @REM work with both Windows and non-Windows executions. set MAVEN_CMD_LINE_ARGS=%* diff --git a/org.eclipse.transformer.cli/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.transformer.cli/.settings/org.eclipse.jdt.core.prefs index e8532c39..c772cad8 100644 --- a/org.eclipse.transformer.cli/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.transformer.cli/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -150,7 +150,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME diff --git a/org.eclipse.transformer.cli/pom.xml b/org.eclipse.transformer.cli/pom.xml index 442c4405..29c8d9f4 100644 --- a/org.eclipse.transformer.cli/pom.xml +++ b/org.eclipse.transformer.cli/pom.xml @@ -100,6 +100,7 @@ jar + diff --git a/org.eclipse.transformer.cli/src/test/java/transformer/test/TestCommandLine.java b/org.eclipse.transformer.cli/src/test/java/transformer/test/TestCommandLine.java index 0df4629f..9b507d7d 100644 --- a/org.eclipse.transformer.cli/src/test/java/transformer/test/TestCommandLine.java +++ b/org.eclipse.transformer.cli/src/test/java/transformer/test/TestCommandLine.java @@ -218,8 +218,7 @@ void zip_non_UTF_8_encoding() throws Exception { transformer.transform(); Changes lastActiveChanges = transformer.getLastActiveChanges(); - if (lastActiveChanges instanceof ContainerChanges) { - ContainerChanges containerChanges = (ContainerChanges) lastActiveChanges; + if (lastActiveChanges instanceof ContainerChanges containerChanges) { int numDuplicated = containerChanges.getAllDuplicated(); int numFailed = containerChanges.getAllFailed(); @@ -391,8 +390,7 @@ private void verifyAction(String actionClassName, String inputFileName, String o transformer.transform(); Changes lastActiveChanges = transformer.getLastActiveChanges(); - if (lastActiveChanges instanceof ContainerChanges) { - ContainerChanges containerChanges = (ContainerChanges) lastActiveChanges; + if (lastActiveChanges instanceof ContainerChanges containerChanges) { int numDuplicated = containerChanges.getAllDuplicated(); int numFailed = containerChanges.getAllFailed(); @@ -432,7 +430,7 @@ private void verifyActionInvalidDirectoryRejected(String actionClassName, String private static Map extractSignatureFileEntries(String zipFilePath) throws IOException { try (ZipFile zipFile = new ZipFile(zipFilePath)) { final Enumeration entries = zipFile.entries(); - final Map signatureFilesMap = new HashMap(); + final Map signatureFilesMap = new HashMap<>(); while (entries.hasMoreElements()) { final ZipEntry zipEntry = entries.nextElement(); if (ElementAction.SIGNATURE_FILE_PATTERN.matcher(zipEntry.getName()).matches()) { diff --git a/org.eclipse.transformer.jakarta/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.transformer.jakarta/.settings/org.eclipse.jdt.core.prefs index e8532c39..c772cad8 100644 --- a/org.eclipse.transformer.jakarta/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.transformer.jakarta/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -150,7 +150,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME diff --git a/org.eclipse.transformer.parent/pom.xml b/org.eclipse.transformer.parent/pom.xml index 1378d754..1c3418e8 100644 --- a/org.eclipse.transformer.parent/pom.xml +++ b/org.eclipse.transformer.parent/pom.xml @@ -22,14 +22,12 @@ ${revision} - 0.6.0-SNAPSHOT + 1.0.0-SNAPSHOT UTF-8 UTF-8 - 1.8 - 8 - ${java.version} - ${java.version} - 6.4.0 + 17 + ${java.release} + 7.0.0 5.11.0 3.26.3 2.10.0 @@ -102,6 +100,7 @@ jar + ${basedir}/src/it ${basedir}/src/it/settings.xml ${project.build.directory}/it-repo - true ${project.build.directory}/it true ${project.build.sourceEncoding} ${project.reporting.outputEncoding} - ${maven.compiler.source} - ${maven.compiler.target} ${maven.compiler.release} ${revision} ${bnd.version} + ${env.MAVEN_OPTS} */pom.xml @@ -574,15 +571,6 @@ SPDX-License-Identifier: ${project.licenses[0].name} - - java-release - - [9,) - - - ${java.release} - - pinentrymode-loopback @@ -609,6 +597,7 @@ SPDX-License-Identifier: ${project.licenses[0].name} maven-gpg-plugin + ${gpg.pinentrymode} @@ -633,7 +622,7 @@ SPDX-License-Identifier: ${project.licenses[0].name} bnd-snapshot - 7.0.0-SNAPSHOT + 7.1.0-SNAPSHOT diff --git a/org.eclipse.transformer/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.transformer/.settings/org.eclipse.jdt.core.prefs index e8532c39..c772cad8 100644 --- a/org.eclipse.transformer/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.transformer/.settings/org.eclipse.jdt.core.prefs @@ -30,9 +30,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.compliance=17 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -72,7 +72,7 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore @@ -150,7 +150,7 @@ org.eclipse.jdt.core.compiler.problem.unusedWarningToken=ignore org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.processAnnotations=disabled org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.compiler.source=17 org.eclipse.jdt.core.compiler.taskCaseSensitive=enabled org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,NORMAL org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/ImmediateRuleData.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/ImmediateRuleData.java index b615613e..6043e64d 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/ImmediateRuleData.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/ImmediateRuleData.java @@ -11,14 +11,5 @@ package org.eclipse.transformer; -public class ImmediateRuleData { - public final AppOption target; - public final String key; - public final String value; - - public ImmediateRuleData(AppOption target, String key, String value) { - this.target = target; - this.key = key; - this.value = value; - } +public record ImmediateRuleData(AppOption target, String key, String value) { } diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/TransformProperties.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/TransformProperties.java index bc6eb12b..d76bab4d 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/TransformProperties.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/TransformProperties.java @@ -148,7 +148,7 @@ public static void setPackageVersions( } else if ( nextChar == ';' ) { // The length test guards against 'p=v;a1=v1;;a2=v2' - if ( versionBuilder.length() != 0 ) { + if (!versionBuilder.isEmpty()) { setVersion( newPackageName, newVersion, nameBuilder, versionBuilder, @@ -165,7 +165,7 @@ public static void setPackageVersions( // // See issue #300. - if ( nameBuilder.length() != 0 ) { + if (!nameBuilder.isEmpty()) { throw new IllegalArgumentException("Package version syntax error: Version missing for package [ " + newPackageName + " ] and attribute [ " + nameBuilder.toString() + " ]"); } } @@ -184,7 +184,7 @@ public static void setPackageVersions( // end with a ';', in which case the builders will be empty, // and there is no update to be done. - if ( versionBuilder.length() != 0 ) { + if (!versionBuilder.isEmpty()) { setVersion( newPackageName, newVersion, nameBuilder, versionBuilder, @@ -206,7 +206,7 @@ public static void setVersion( Map> specificPackageVersions) { String versionText; - if ( versionBuilder.length() == 0 ) { + if (versionBuilder.isEmpty()) { throw new IllegalArgumentException("Package version syntax error: No version in [ " + newVersion + " ]"); } else { versionText = versionBuilder.toString(); @@ -214,7 +214,7 @@ public static void setVersion( } String propertyName; - if ( nameBuilder.length() == 0 ) { + if (nameBuilder.isEmpty()) { propertyName = null; } else { propertyName = nameBuilder.toString(); @@ -224,10 +224,7 @@ public static void setVersion( if ( propertyName == null ) { packageVersions.put(newPackageName, versionText); } else { - Map versionsForProperty = specificPackageVersions.get(propertyName); - if ( versionsForProperty == null ) { - specificPackageVersions.put( propertyName, (versionsForProperty = new HashMap<>()) ); - } + Map versionsForProperty = specificPackageVersions.computeIfAbsent(propertyName, k -> new HashMap<>()); versionsForProperty.put(newPackageName, versionText); } } @@ -266,7 +263,6 @@ public static > MAP copyPropertiesToMap(Properti * file. * @throws TransformException Thrown if an error occurs processing the file. */ - @SuppressWarnings("resource") public static boolean isFeatureManifest(String manifestPath, File manifestFile) throws TransformException { FileReader manifestReader; try { diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/Transformer.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/Transformer.java index f953079b..8f2fda4c 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/Transformer.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/Transformer.java @@ -47,7 +47,6 @@ import org.eclipse.transformer.action.ContainerChanges; import org.eclipse.transformer.action.SelectionRule; import org.eclipse.transformer.action.SignatureRule; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.ActionSelectorImpl; import org.eclipse.transformer.action.impl.BundleDataImpl; import org.eclipse.transformer.action.impl.ClassActionImpl; @@ -207,8 +206,7 @@ protected ResultCode basicRun() { } Changes lastActiveChanges = getLastActiveChanges(); - if (lastActiveChanges instanceof ContainerChanges) { - ContainerChanges containerChanges = (ContainerChanges) lastActiveChanges; + if (lastActiveChanges instanceof ContainerChanges containerChanges) { int numDuplicated = containerChanges.getAllDuplicated(); int numFailed = containerChanges.getAllFailed(); @@ -458,28 +456,28 @@ protected void processImmediateData( throws IOException, URISyntaxException { for ( ImmediateRuleData nextData : immediateData ) { - switch ( nextData.target ) { + switch ( nextData.target() ) { case RULES_SELECTIONS: - addImmediateSelection(nextData.key, nextData.value); + addImmediateSelection(nextData.key(), nextData.value()); break; case RULES_RENAMES: - addImmediateRename(nextData.key, nextData.value, orphanedFinalVersions); + addImmediateRename(nextData.key(), nextData.value(), orphanedFinalVersions); break; case RULES_VERSIONS: - addImmediateVersion(nextData.key, nextData.value); + addImmediateVersion(nextData.key(), nextData.value()); break; case RULES_BUNDLES: - addImmediateBundleData(nextData.key, nextData.value); + addImmediateBundleData(nextData.key(), nextData.value()); break; case RULES_DIRECT: - addImmediateDirect(nextData.key, nextData.value); + addImmediateDirect(nextData.key(), nextData.value()); break; case RULES_MASTER_TEXT: - addImmediateMasterText(masterTextRef, nextData.key, nextData.value); + addImmediateMasterText(masterTextRef, nextData.key(), nextData.value()); break; default: - getLogger().error(consoleMarker, "Unrecognized immediate data target [ {} ]", nextData.target); + getLogger().error(consoleMarker, "Unrecognized immediate data target [ {} ]", nextData.target()); } } } @@ -1103,7 +1101,7 @@ private boolean outputExists(File outputFile) { // As a separate method to allow re-use. public ActionContext getActionContext() { - return new ActionContextImpl(getLogger(), getSelectionRule(), getSignatureRule()); + return new ActionContext(getLogger(), getSelectionRule(), getSignatureRule()); } public ActionSelector getActionSelector() { diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ActionContext.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ActionContext.java index 62265d42..8646db48 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ActionContext.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ActionContext.java @@ -19,10 +19,13 @@ import org.slf4j.Logger; -public interface ActionContext { - Logger getLogger(); +import static java.util.Objects.requireNonNull; - SelectionRule getSelectionRule(); - - SignatureRule getSignatureRule(); +public record ActionContext(Logger logger, SelectionRule selectionRule, + SignatureRule signatureRule) { + public ActionContext(Logger logger, SelectionRule selectionRule, SignatureRule signatureRule) { + this.logger = requireNonNull(logger); + this.selectionRule = requireNonNull(selectionRule); + this.signatureRule = requireNonNull(signatureRule); + } } diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ByteData.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ByteData.java index 6e891362..256fff2e 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ByteData.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/ByteData.java @@ -48,9 +48,6 @@ public interface ByteData { * data. The settings of the copy buffer (length, limit, and remaining) * start the same as the settings of the buffer of this data, but are * updated independently. - *

- * For a buffer which has its position set to zero, use instead - * {@link #buffer()}. * * @return The buffer associated with the data. */ diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionContextImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionContextImpl.java deleted file mode 100644 index 9ccfe697..00000000 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionContextImpl.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) Contributors to the Eclipse Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - *******************************************************************************/ -package org.eclipse.transformer.action.impl; - -import static java.util.Objects.requireNonNull; - -import org.eclipse.transformer.action.ActionContext; -import org.eclipse.transformer.action.SelectionRule; -import org.eclipse.transformer.action.SignatureRule; -import org.slf4j.Logger; - -public class ActionContextImpl implements ActionContext { - public ActionContextImpl(Logger logger, SelectionRule selectionRule, SignatureRule signatureRule) { - this.logger = requireNonNull(logger); - this.selectionRule = requireNonNull(selectionRule); - this.signatureRule = requireNonNull(signatureRule); - } - - private final Logger logger; - private final SelectionRule selectionRule; - private final SignatureRule signatureRule; - - @Override - public Logger getLogger() { - return logger; - } - - @Override - public SelectionRule getSelectionRule() { - return selectionRule; - } - - @Override - public SignatureRule getSignatureRule() { - return signatureRule; - } -} diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionImpl.java index b26ec5f1..822be386 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ActionImpl.java @@ -100,21 +100,21 @@ protected ActionContext getContext() { } protected Logger getLogger() { - return getContext().getLogger(); + return getContext().logger(); } // @Override public SelectionRule getResourceSelectionRule() { - return getContext().getSelectionRule(); + return getContext().selectionRule(); } // @Override public SignatureRule getSignatureRule() { - return getContext().getSignatureRule(); + return getContext().signatureRule(); } public Map getPackageRenames() { diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ClassActionImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ClassActionImpl.java index a56ac061..ed33941f 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ClassActionImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ClassActionImpl.java @@ -240,7 +240,7 @@ private String traceDumpLine(StringBuilder builder, ByteBuffer buffer, int width public ClassActionImpl(ActionContext context) { super(context); - List useReplacements = createActiveReplacements(context.getSignatureRule()); + List useReplacements = createActiveReplacements(context.signatureRule()); this.activeReplacements = useReplacements.isEmpty() ? NO_ACTIVE_REPLACEMENTS : useReplacements; } @@ -1174,8 +1174,7 @@ private ElementValueInfo[] transform(ElementValueInfo[] inputElementValues, Stri private Object transformElementValue(Object inputValue, String inputName, String annotationType, String elementName) { - if (inputValue instanceof EnumConst) { - EnumConst enumValue = (EnumConst) inputValue; + if (inputValue instanceof EnumConst enumValue) { String inputType = enumValue.type; String outputType = transformDescriptor(inputType); if (outputType == null) { @@ -1184,8 +1183,7 @@ private Object transformElementValue(Object inputValue, String inputName, String return new EnumConst(outputType, enumValue.name); } - } else if (inputValue instanceof ResultConst) { - ResultConst resultValue = (ResultConst) inputValue; + } else if (inputValue instanceof ResultConst resultValue) { String inputDescriptor = resultValue.descriptor; String outputDescriptor = transformDescriptor(inputDescriptor); if (outputDescriptor == null) { @@ -1194,12 +1192,10 @@ private Object transformElementValue(Object inputValue, String inputName, String return new ResultConst(outputDescriptor); } - } else if (inputValue instanceof AnnotationInfo) { - AnnotationInfo annotationValue = (AnnotationInfo) inputValue; + } else if (inputValue instanceof AnnotationInfo annotationValue) { return transform(annotationValue, AnnotationInfo::new, inputName); - } else if (inputValue instanceof String) { - String stringValue = (String) inputValue; + } else if (inputValue instanceof String stringValue) { String result = transformString(inputName, "AnnotationValue", stringValue); // Replace package version in OSGi Version annotation. if (inputName.endsWith("/package-info.class") @@ -1213,8 +1209,7 @@ private Object transformElementValue(Object inputValue, String inputName, String } } return result; - } else if (inputValue instanceof Object[]) { - Object[] inputElementValues = ((Object[]) inputValue); + } else if (inputValue instanceof Object[] inputElementValues) { Object[] outputElementValues = null; for (int valueNo = 0; valueNo < inputElementValues.length; valueNo++) { @@ -1255,10 +1250,9 @@ private VerificationTypeInfo[] transform(VerificationTypeInfo[] inputVtis) { } private VerificationTypeInfo transform(VerificationTypeInfo vti) { - if (!(vti instanceof ObjectVariableInfo)) { + if (!(vti instanceof ObjectVariableInfo inputOvi)) { return null; } - ObjectVariableInfo inputOvi = (ObjectVariableInfo) vti; String inputType = inputOvi.type; if (inputType == null) { @@ -1287,6 +1281,7 @@ private int transform(MutableConstantPool constants, String inputName) throws Tr int numConstants = constants.size(); for (int constantNo = 1; constantNo < numConstants; constantNo++) { if (useLogger.isTraceEnabled()) { + //noinspection StringConcatenationArgumentToLogCall useLogger .trace(String.format("Constant [ %3s ] [ %16s ] [ %s ]", constantNo, constants.tag(constantNo), constants.entry(constantNo))); diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ContainerActionImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ContainerActionImpl.java index 36567ec1..b87ad3fb 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ContainerActionImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ContainerActionImpl.java @@ -104,7 +104,7 @@ protected void recordAction(Action action, String resourceName) { protected void recordError(Action action, String resourceName, Throwable error) { String actionName = ( (action == null) ? "null" : action.getName() ); - getLogger().error("Resource [ " + resourceName + " ] Action [ " + actionName + " ]: Failed transform", error); + getLogger().error("Resource [ {} ] Action [ {} ]: Failed transform", resourceName, actionName, error); getActiveChanges().recordFailed(action); } diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ManifestActionImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ManifestActionImpl.java index db9d45c1..4ba70a1c 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ManifestActionImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ManifestActionImpl.java @@ -550,10 +550,7 @@ protected boolean firstCharIsSemicolon(String s) { if (Character.isWhitespace(s.charAt(i))) { continue; } - if (s.charAt(i) == ';') { - return true; - } - return false; + return s.charAt(i) == ';'; } return false; } @@ -581,10 +578,7 @@ private boolean isPackageDelimitingComma(String testString, String packageText, int indexOfNextNonWhiteSpaceCharAfterComma = indexOfNextNonWhiteSpaceChar(testString, indexOfComma + 1); char characterAfterComma = testString.charAt(indexOfNextNonWhiteSpaceCharAfterComma); if (Character.isAlphabetic(characterAfterComma)) { - if (!hasEvenNumberOfOccurrencesOfChar(packageText, '\"')) { - return false; - } - return true; + return hasEvenNumberOfOccurrencesOfChar(packageText, '\"'); } return false; diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/SignatureRuleImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/SignatureRuleImpl.java index b49197fc..ddad64ba 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/SignatureRuleImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/SignatureRuleImpl.java @@ -548,7 +548,7 @@ private String replaceTextDirect(String initialValue, String inputName, Map - * See {@replacePackage}. + * See {@link #replacePackage(String)}. * * @param inputName The input name which is to be renamed. * @return The updated name. Null if no change is to be made. diff --git a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ZipActionImpl.java b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ZipActionImpl.java index e90031e7..5b17b972 100644 --- a/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ZipActionImpl.java +++ b/org.eclipse.transformer/src/main/java/org/eclipse/transformer/action/impl/ZipActionImpl.java @@ -346,9 +346,7 @@ private void applyZipStream( ByteData inputData = collect(inputName, zipInputStream, inputLength); ByteData outputData = zipAction.apply(inputData); ZipEntry outputEntry = createEntry(inputEntry, outputName, outputData); - putEntry(zipOutputStream, outputEntry, () -> { - outputData.writeTo(zipOutputStream); - }); + putEntry(zipOutputStream, outputEntry, () -> outputData.writeTo(zipOutputStream)); } else { // For COMPRESSED, we use streaming. // Loading entire archives into memory is to be avoided. @@ -481,9 +479,7 @@ public void writeUnmodified( getLogger().trace("Write unmodified entry [ {} ] bytes [ {} ]", outputName, outputData.length()); ZipEntry outputEntry = copyEntry(inputEntry, outputName); - putEntry(zipOutputStream, outputEntry, () -> { - outputData.writeTo(zipOutputStream); - }); + putEntry(zipOutputStream, outputEntry, () -> outputData.writeTo(zipOutputStream)); } public void writeModified( @@ -494,9 +490,7 @@ public void writeModified( getLogger().trace("Write modified entry [ {} ] bytes [ {} ]", outputName, outputData.length()); ZipEntry outputEntry = createEntry(inputEntry, outputName, outputData); - putEntry(zipOutputStream, outputEntry, () -> { - outputData.writeTo(zipOutputStream); - }); + putEntry(zipOutputStream, outputEntry, () -> outputData.writeTo(zipOutputStream)); } private ZipEntry createEntry(ZipEntry inputEntry, String outputName) { diff --git a/org.eclipse.transformer/src/test/java/transformer/test/ClassActionTest.java b/org.eclipse.transformer/src/test/java/transformer/test/ClassActionTest.java index 09423398..ef8a62d0 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/ClassActionTest.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/ClassActionTest.java @@ -40,7 +40,6 @@ import org.assertj.core.api.recursive.comparison.RecursiveComparisonConfiguration; import org.eclipse.transformer.action.ActionContext; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.ByteDataImpl; import org.eclipse.transformer.action.impl.ClassActionImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; @@ -120,7 +119,7 @@ public void module_transform() throws Exception { renames.put("original.provides.impl", "transformed.provides.impl"); renames.put("original.main", "transformed.main"); - ActionContext context = new ActionContextImpl(logger, + ActionContext context = new ActionContext(logger, new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()), new SignatureRuleImpl(logger, renames, null, null, null, null, null, Collections.emptyMap())); ClassActionImpl classAction = new ClassActionImpl(context); @@ -216,7 +215,7 @@ public void nest_transform() throws Exception { Map renames = new HashMap<>(); renames.put("original.host", "transformed.host"); renames.put("original.member", "transformed.member"); - ActionContext context = new ActionContextImpl(logger, + ActionContext context = new ActionContext(logger, new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()), new SignatureRuleImpl(logger, renames, null, null, null, null, null, Collections.emptyMap())); @@ -260,7 +259,7 @@ public void enclosing_method_transform() throws Exception { renames.put("original.enclosing", "transformed.enclosing"); renames.put("original.param", "transformed.param"); renames.put("original.result", "transformed.result"); - ActionContext context = new ActionContextImpl(logger, + ActionContext context = new ActionContext(logger, new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()), new SignatureRuleImpl(logger, renames, null, null, null, null, null, Collections.emptyMap())); ClassActionImpl classAction = new ClassActionImpl(context); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/RenameActionTest.java b/org.eclipse.transformer/src/test/java/transformer/test/RenameActionTest.java index 3555a07b..fb4a5281 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/RenameActionTest.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/RenameActionTest.java @@ -18,7 +18,6 @@ import aQute.bnd.unmodifiable.Maps; import org.eclipse.transformer.action.ActionContext; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.RenameActionImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; import org.eclipse.transformer.action.impl.SignatureRuleImpl; @@ -48,7 +47,7 @@ public void setUp(TestInfo testInfo) { @Test void relocate_resource() { - ActionContext context = new ActionContextImpl(logger, + ActionContext context = new ActionContext(logger, new SelectionRuleImpl(logger, Collections.emptyMap(), Collections.emptyMap()), new SignatureRuleImpl(logger, Maps.of("com.a.b.*", "com.shaded.a.b"), null, null, null, null, null, Collections.emptyMap())); RenameActionImpl action = new RenameActionImpl(context); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/SelectionTests.java b/org.eclipse.transformer/src/test/java/transformer/test/SelectionTests.java index e32e9cb1..c6c19948 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/SelectionTests.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/SelectionTests.java @@ -35,17 +35,16 @@ class SelectionTests { @Test void selections() throws Exception { UTF8Properties properties = new UTF8Properties(); - properties.load("# comment\n" + - "*=UTF-8\n" + - "*.properties=ISO-8859-1\n" + - "*Abstract*=US-ASCII\n" + - "wide/*=UTF-16\n" + - "! comment\n" + - "*.proto=!", null, null); + properties.load(""" + # comment + *=UTF-8 + *.properties=ISO-8859-1 + *Abstract*=US-ASCII + wide/*=UTF-16 + ! comment + *.proto=!""", null, null); Map selectionProperties = new HashMap<>(); - properties.forEach((k,v) -> { - selectionProperties.put(k.toString(), v.toString()); - }); + properties.forEach((k,v) -> selectionProperties.put(k.toString(), v.toString())); Map includes = new HashMap<>(); Map excludes = new HashMap<>(); TransformProperties.addSelections(includes, excludes, selectionProperties); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformClass.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformClass.java index e7aaae33..c9d0a11c 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformClass.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformClass.java @@ -44,7 +44,6 @@ import org.eclipse.transformer.action.ActionContext; import org.eclipse.transformer.action.ActionType; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.ClassActionImpl; import org.eclipse.transformer.action.impl.ClassChangesImpl; import org.eclipse.transformer.action.impl.ServiceLoaderConfigActionImpl; @@ -246,9 +245,7 @@ public Map getToJakartaRenames() { public void displayJakartaPackageRenames() { System.out.println("Package Renames [ javax -> jakarta ]"); - getToJakartaRenames().forEach((key, value) -> { - System.out.println(" [ " + key + " ] --> [ " + value + " ]"); - }); + getToJakartaRenames().forEach((key, value) -> System.out.println(" [ " + key + " ] --> [ " + value + " ]")); } // @@ -279,9 +276,7 @@ public Map toJakartaDirectStrings() { public void displayJakartaGlobalDirectStrings() { System.out.println("Global Direct Strings [ javax -> jakarta ]"); - toJakartaDirectStrings().forEach((key, value) -> { - System.out.println(" [ " + key + " ] --> [ " + value + " ]"); - }); + toJakartaDirectStrings().forEach((key, value) -> System.out.println(" [ " + key + " ] --> [ " + value + " ]")); } protected static final String PER_CLASS_OVERRIDE_PACKAGE_NAME = "transformer.test.data2"; @@ -303,9 +298,7 @@ public void displayJakartaPerClassDirectStrings() { System.out.println("Per Class Direct Strings [ javax -> jakarta ]"); toJakartaPerClassDirectStrings().forEach((className, directStrings) -> { System.out.println(" [ " + className + " ]:"); - directStrings.forEach((key, value) -> { - System.out.println(" [ " + key + " ] --> [ " + value + " ]"); - }); + directStrings.forEach((key, value) -> System.out.println(" [ " + key + " ] --> [ " + value + " ]")); }); } @@ -341,7 +334,7 @@ public ZipActionImpl getJavaxToJakartaJarAction() { if (toJakartaJarAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getIncludes(), getExcludes()), createSignatureRule(useLogger, getToJakartaRenames(), null, null, null, Collections.emptyMap())); @@ -359,7 +352,7 @@ public ZipActionImpl getJakartaToJavaxJarAction() { Map toJavaxRenames = TransformProperties.invert(getToJakartaRenames()); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getIncludes(), getExcludes()), createSignatureRule(useLogger, toJavaxRenames, null, null, null, Collections.emptyMap())); @@ -375,7 +368,7 @@ public ZipActionImpl getJavaxToJakartaJarAction_DirectOverride() { if (toJakartaJarAction_DirectOverride == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getOverrideIncludes(), getExcludes()), createSignatureRule(useLogger, getToJakartaRenames(), null, null, toJakartaDirectStrings(), null)); @@ -391,7 +384,7 @@ public ZipActionImpl getJavaxToJakartaJarAction_PerClassDirectOverride() { if (toJakartaJarAction_PerClassDirectOverride == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getOverrideIncludes(), getExcludes()), createSignatureRule(useLogger, getToJakartaRenames(), null, null, toJakartaDirectStrings(), toJakartaPerClassDirectStrings())); @@ -408,7 +401,7 @@ public ZipActionImpl getJavaxToJakartaJarAction_PackageRenamesOnly() { if (toJakartaJarAction_PackageRenamesOnly == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getOverrideIncludes(), getExcludes()), createSignatureRule(useLogger, getToJakartaRenames(), null, null, null, null)); @@ -521,7 +514,7 @@ public static Map loadRenames(String resourceRef) throws IOExcep public ClassActionImpl createToJakartaClassAction() { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, Collections.emptyMap(), Collections.emptyMap()), createSignatureRule(useLogger, getToJakartaRenames(), null, null, null, Collections.emptyMap())); @@ -584,7 +577,7 @@ protected void display(String msg, Object... parms) { if (parms.length == 0) { System.out.println(msg); } else { - System.out.println(String.format(msg, parms)); + System.out.printf((msg) + "%n", parms); } } @@ -822,7 +815,7 @@ public static final Map getDirectStrings() { public ClassActionImpl createDirectClassAction() { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, Collections.emptyMap(), Collections.emptyMap()), createSignatureRule( useLogger, Collections.emptyMap(), null, null, getDirectStrings(), Collections.emptyMap())); @@ -832,7 +825,7 @@ public ClassActionImpl createDirectClassAction() { public ClassActionImpl createPerClassConstantClassAction() { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, Collections.emptyMap(), Collections.emptyMap()), createSignatureRule(useLogger, Collections.emptyMap(), null, null, null, PER_CLASS_CONSTANT_MASTER)); @@ -929,26 +922,8 @@ public void testPerClassConstant() throws TransformException, IOException { public static final boolean IS_EXACT = false; - public static class ClassRelocation { - public final String inputPath; - public final String inputName; - - public final String outputName; - public final String outputPath; - - public final boolean isApproximate; - - public ClassRelocation(String inputPath, String inputName, String outputName, String outputPath, - boolean isApproximate) { - - this.inputPath = inputPath; - this.inputName = inputName; - - this.outputName = outputName; - this.outputPath = outputPath; - - this.isApproximate = isApproximate; - } + public record ClassRelocation(String inputPath, String inputName, String outputName, String outputPath, + boolean isApproximate) { } public static ClassRelocation[] RELOCATION_CASES = new ClassRelocation[] { @@ -978,13 +953,16 @@ public ClassRelocation(String inputPath, String inputName, String outputName, St public void testClassRelocation() { ClassActionImpl classAction = createDirectClassAction(); for (ClassRelocation relocationCase : RELOCATION_CASES) { - String outputPath = classAction.relocateClass(relocationCase.inputPath, - relocationCase.inputName, relocationCase.outputName); + String outputPath = classAction.relocateClass(relocationCase.inputPath(), + relocationCase.inputName(), relocationCase.outputName()); List capturedEvents = consumeCapturedEvents(); - System.out.printf("Relocation [ %s ] as [ %s ]\n" + " to [ %s ] as [ %s ]\n", - relocationCase.inputPath, relocationCase.inputName, relocationCase.outputName, outputPath); + System.out.printf(""" + Relocation [ %s ] as [ %s ] + to [ %s ] as [ %s ] + """, + relocationCase.inputPath(), relocationCase.inputName(), relocationCase.outputName(), outputPath); boolean capturedApproximate = false; for (CaptureLoggerImpl.LogEvent event : capturedEvents) { @@ -994,9 +972,9 @@ public void testClassRelocation() { } } - Assertions.assertEquals(relocationCase.outputPath, outputPath, "Incorrect output path"); + Assertions.assertEquals(relocationCase.outputPath(), outputPath, "Incorrect output path"); - Assertions.assertEquals(capturedApproximate, relocationCase.isApproximate, "Approximate error not logged"); + Assertions.assertEquals(capturedApproximate, relocationCase.isApproximate(), "Approximate error not logged"); } } @@ -1197,7 +1175,7 @@ public static Map getStandardRenames() throws IOException { public ClassActionImpl createStandardClassAction() throws IOException { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, Collections.emptyMap(), Collections.emptyMap()), createSignatureRule(useLogger, getStandardRenames(), null, null, null, Collections.emptyMap())); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformManifest.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformManifest.java index 5df5c906..9d15b205 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformManifest.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformManifest.java @@ -30,7 +30,6 @@ import org.eclipse.transformer.action.ActionType; import org.eclipse.transformer.action.BundleData; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.BundleDataImpl; import org.eclipse.transformer.action.impl.ManifestActionImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; @@ -197,7 +196,7 @@ public ManifestActionImpl getJakartaManifestAction() { if (jakartaManifestAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), null, getBundleUpdates(), null, getDirectStrings(), Collections.emptyMap())); @@ -213,7 +212,7 @@ public ManifestActionImpl getJakartaFeatureAction() { if (jakartaFeatureAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), null, null, null, null, Collections.emptyMap())); @@ -232,7 +231,7 @@ public ManifestActionImpl getJakartaManifestActionTx() { if (jakartaManifestActionTx == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), null, getBundleUpdatesTx(), null, getDirectStrings(), Collections.emptyMap())); @@ -249,7 +248,7 @@ public ManifestActionImpl getSpecificJakartaManifestAction() { if (specificJakartaManifestAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), getSpecificPackageVersions(), getBundleUpdatesTx(), null, getDirectStrings(), Collections.emptyMap())); @@ -262,55 +261,37 @@ public ManifestActionImpl getSpecificJakartaManifestAction() { // - protected static final class Occurrences { - public final String initialTag; - public final int initialTagInitialCount; - public final int initialTagFinalCount; - - public final String finalTag; - public final int finalTagInitialCount; - public final int finalTagFinalCount; - - public Occurrences(String initialTag, int initialTagInitialCount, int initialTagFinalCount, String finalTag, - int finalTagInitialCount, int finalTagFinalCount) { - - this.initialTag = initialTag; - this.initialTagInitialCount = initialTagInitialCount; - this.initialTagFinalCount = initialTagFinalCount; - - this.finalTag = finalTag; - this.finalTagInitialCount = finalTagInitialCount; - this.finalTagFinalCount = finalTagFinalCount; - } + public record Occurrences(String initialTag, int initialTagInitialCount, int initialTagFinalCount, + String finalTag, int finalTagInitialCount, int finalTagFinalCount) { public void verifyInitial(List lines) { - int actualInitialTagInitial = TestUtils.occurrences(lines, initialTag); - System.out.println("Tag [ " + initialTag + " ]" + - " Expected [ " + initialTagInitialCount + " ]" + - " Actual [ " + actualInitialTagInitial + " ]"); - Assertions.assertEquals(initialTagInitialCount, actualInitialTagInitial, initialTag); - - int actualFinalTagInitial = TestUtils.occurrences(lines, finalTag); - System.out.println("Tag [ " + finalTag + " ]" + - " Expected [ " + finalTagInitialCount + " ]" + - " Actual [ " + actualFinalTagInitial + " ]"); - Assertions.assertEquals(finalTagInitialCount, actualFinalTagInitial, initialTag); - } + int actualInitialTagInitial = TestUtils.occurrences(lines, initialTag()); + System.out.println("Tag [ " + initialTag() + " ]" + + " Expected [ " + initialTagInitialCount() + " ]" + + " Actual [ " + actualInitialTagInitial + " ]"); + Assertions.assertEquals(initialTagInitialCount(), actualInitialTagInitial, initialTag()); + + int actualFinalTagInitial = TestUtils.occurrences(lines, finalTag()); + System.out.println("Tag [ " + finalTag() + " ]" + + " Expected [ " + finalTagInitialCount() + " ]" + + " Actual [ " + actualFinalTagInitial + " ]"); + Assertions.assertEquals(finalTagInitialCount(), actualFinalTagInitial, initialTag()); + } - public void verifyFinal(List lines) { - int actualInitialTagFinal = TestUtils.occurrences(lines, initialTag); - System.out.println("Tag [ " + initialTag + " ]" + - " Expected [ " + initialTagFinalCount + " ]" + - " Actual [ " + actualInitialTagFinal + " ]"); - Assertions.assertEquals(initialTagFinalCount, actualInitialTagFinal, initialTag); - - int actualFinalTagFinal = TestUtils.occurrences(lines, finalTag); - System.out.println("Tag [ " + finalTag + " ]" + - " Expected [ " + finalTagFinalCount + " ]" + - " Actual [ " + actualFinalTagFinal + " ]"); - Assertions.assertEquals(finalTagFinalCount, actualFinalTagFinal, initialTag); + public void verifyFinal(List lines) { + int actualInitialTagFinal = TestUtils.occurrences(lines, initialTag()); + System.out.println("Tag [ " + initialTag() + " ]" + + " Expected [ " + initialTagFinalCount() + " ]" + + " Actual [ " + actualInitialTagFinal + " ]"); + Assertions.assertEquals(initialTagFinalCount(), actualInitialTagFinal, initialTag()); + + int actualFinalTagFinal = TestUtils.occurrences(lines, finalTag()); + System.out.println("Tag [ " + finalTag() + " ]" + + " Expected [ " + finalTagFinalCount() + " ]" + + " Actual [ " + actualFinalTagFinal + " ]"); + Assertions.assertEquals(finalTagFinalCount(), actualFinalTagFinal, initialTag()); + } } - } // @@ -614,7 +595,7 @@ public void testTransformManifest_Transaction() throws TransformException, IOExc /** * Subclass which allows us to call protected methods of ManifestActionImpl */ - class ManifestActionImpl_Test extends ManifestActionImpl { + protected static class ManifestActionImpl_Test extends ManifestActionImpl { public ManifestActionImpl_Test(ActionContext context) { super(context, ActionType.MANIFEST); } @@ -642,7 +623,7 @@ protected ManifestActionImpl_Test getManifestAction() { if (manifestAction_test == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), null, null, null, null, Collections.emptyMap())); manifestAction_test = new ManifestActionImpl_Test(context); @@ -657,7 +638,7 @@ protected ManifestActionImpl_Test getSpecificManifestAction() { if (specificManifestAction_test == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, getPackageRenames(), getPackageVersions(), getSpecificPackageVersions(), diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformPropertiesFile.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformPropertiesFile.java index 4da81a71..f13730f1 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformPropertiesFile.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformPropertiesFile.java @@ -21,7 +21,6 @@ import org.eclipse.transformer.TransformException; import org.eclipse.transformer.action.ActionContext; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.PropertiesActionImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; import org.eclipse.transformer.action.impl.SignatureRuleImpl; @@ -105,7 +104,7 @@ public PropertiesActionImpl getJakartaPropertiesAction() { if (jakartaPropertiesAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getIncludes(), getExcludes()), createSignatureRule(useLogger, getPackageRenames(), getDirectStrings())); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformServiceConfig.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformServiceConfig.java index 565e6d1d..36614a4a 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformServiceConfig.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformServiceConfig.java @@ -29,7 +29,6 @@ import org.eclipse.transformer.action.ActionType; import org.eclipse.transformer.action.BundleData; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.PropertiesActionImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; import org.eclipse.transformer.action.impl.ServiceLoaderConfigActionImpl; @@ -159,7 +158,7 @@ public ServiceLoaderConfigActionImpl getJakartaServiceAction() { if (jakartaServiceAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getIncludes(), getExcludes()), createSignatureRule(useLogger, getPackageRenames(), null, null, null)); @@ -174,7 +173,7 @@ public ServiceLoaderConfigActionImpl getJavaxServiceAction() { Map invertedRenames = TransformProperties.invert(getPackageRenames()); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, getIncludes(), getExcludes()), createSignatureRule(useLogger, invertedRenames, null, null, null)); @@ -189,7 +188,7 @@ public ZipActionImpl getJarJavaxServiceAction() { Map invertedRenames = TransformProperties.invert(getPackageRenames()); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, createSelectionRule(useLogger, Collections.emptyMap(), getExcludes()), createSignatureRule(useLogger, invertedRenames, null, null, null)); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformXML.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformXML.java index 4a8fc8cf..7dbfa6d5 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformXML.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformXML.java @@ -22,7 +22,6 @@ import org.eclipse.transformer.TransformException; import org.eclipse.transformer.action.ActionContext; import org.eclipse.transformer.action.ByteData; -import org.eclipse.transformer.action.impl.ActionContextImpl; import org.eclipse.transformer.action.impl.SelectionRuleImpl; import org.eclipse.transformer.action.impl.SignatureRuleImpl; import org.eclipse.transformer.action.impl.TextActionImpl; @@ -102,7 +101,7 @@ public TextActionImpl getTextAction() { if (textAction == null) { CaptureLoggerImpl useLogger = getCaptureLogger(); - ActionContext context = new ActionContextImpl(useLogger, + ActionContext context = new ActionContext(useLogger, new SelectionRuleImpl(useLogger, getIncludes(), getExcludes()), new SignatureRuleImpl(useLogger, null, null, null, null, getMasterXmlUpdates(), null, Collections.emptyMap())); @@ -114,14 +113,7 @@ public TextActionImpl getTextAction() { // - protected static final class Occurrences { - public final String tag; - public final int count; - - public Occurrences(String tag, int count) { - this.tag = tag; - this.count = count; - } + public record Occurrences(String tag, int count) { } public static final Occurrences[] UT_INITIAL_OCCURRENCES = { @@ -186,8 +178,8 @@ public void verify(String resourceRef, String caseTag, Occurrences[] occurrences System.out.println("Verify [ " + resourceRef + " ] [ " + caseTag + " ] ..."); for (Occurrences occurrence : occurrences) { - String occurrenceTag = occurrence.tag; - int expected = occurrence.count; + String occurrenceTag = occurrence.tag(); + int expected = occurrence.count(); int actual = TestUtils.occurrences(lines, occurrenceTag); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerImmediateRenames.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerImmediateRenames.java index 3509c525..cf49b98c 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerImmediateRenames.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerImmediateRenames.java @@ -78,14 +78,14 @@ void testMultiRenames() throws Exception { TestUtils.verifyPackageVersions("initial package versions", inputFileName, initialPackageVersions, TARGET_ATTRIBUTE_NAME); Map> options = new HashMap<>(); - options.put(AppOption.OVERWRITE, Arrays.asList("true")); - options.put(AppOption.LOG_LEVEL, Arrays.asList("debug")); + options.put(AppOption.OVERWRITE, List.of("true")); + options.put(AppOption.LOG_LEVEL, List.of("debug")); options.put(AppOption.RULES_IMMEDIATE_DATA, Arrays.asList("tr", "javax.package1", "jakarta.package11", // "tr", "javax.package2", "jakarta.package22", // "tv", "jakarta.package11", "1.1.1", // "tv", "jakarta.package22", "2.1.1")); - options.put(AppOption.RULES_RENAMES, Arrays.asList(inputDir + '/' + "tier0.renames.properties")); - options.put(AppOption.RULES_VERSIONS, Arrays.asList(inputDir + '/' + "tier0.versions.properties")); + options.put(AppOption.RULES_RENAMES, List.of(inputDir + '/' + "tier0.renames.properties")); + options.put(AppOption.RULES_VERSIONS, List.of(inputDir + '/' + "tier0.versions.properties")); runTransformer(inputFileName, outputFileName, options, getLogFragments()); TestUtils.verifyPackageVersions("final package versions", outputFileName, finalPackageVersions, TARGET_ATTRIBUTE_NAME); @@ -106,14 +106,14 @@ public List getLogFragments() { public static final Map finalPackageVersions; static { - initialPackageVersions = new HashMap(8); + initialPackageVersions = new HashMap<>(8); initialPackageVersions.put("javax.package0", "0.0.0"); initialPackageVersions.put("javax.package1", "1.0.0"); initialPackageVersions.put("javax.package2", "2.0.0"); initialPackageVersions.put("javax.package3", "3.0.0"); - finalPackageVersions = new HashMap(8); + finalPackageVersions = new HashMap<>(8); finalPackageVersions.put("jakarta.package0", "0.0.1"); finalPackageVersions.put("jakarta.package11", "1.1.1"); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerJava.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerJava.java index f4902273..f236eba2 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerJava.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerJava.java @@ -18,7 +18,6 @@ import java.io.File; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -118,9 +117,9 @@ public static void setUp() throws Exception { System.out.println("Renames [ " + renamesPath + " ]"); options = new HashMap<>(); - options.put(AppOption.OVERWRITE, Arrays.asList("true")); - options.put(AppOption.LOG_LEVEL, Arrays.asList("TRACE")); - options.put(AppOption.RULES_RENAMES, Arrays.asList(renamesPath)); + options.put(AppOption.OVERWRITE, List.of("true")); + options.put(AppOption.LOG_LEVEL, List.of("TRACE")); + options.put(AppOption.RULES_RENAMES, List.of(renamesPath)); System.out.println("Overwrite is enabled"); System.out.println("Logging is set to debug"); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiRenames.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiRenames.java index 14f95254..6b6960a8 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiRenames.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiRenames.java @@ -96,8 +96,8 @@ void testMultiRenames() throws Exception { TestUtils.verifyPackageVersions("initial package versions", inputFileName, initialPackageVersions, TARGET_ATTRIBUTE_NAME); Map> options = new HashMap<>(); - options.put(AppOption.OVERWRITE, Arrays.asList("true")); - options.put(AppOption.LOG_LEVEL, Arrays.asList("debug")); + options.put(AppOption.OVERWRITE, List.of("true")); + options.put(AppOption.LOG_LEVEL, List.of("debug")); options.put(AppOption.RULES_RENAMES, Arrays.asList(inputDir + '/' + "tier0.renames.properties", // inputDir + '/' + "tier1.renames.properties", // inputDir + '/' + "tier2.renames.properties")); @@ -124,7 +124,7 @@ public List getLogFragments() { public static final Map finalPackageVersions; static { - initialPackageVersions = new HashMap(8); + initialPackageVersions = new HashMap<>(8); initialPackageVersions.put("javax.package0", "0.0.0"); initialPackageVersions.put("javax.package1", "1.0.0"); @@ -135,7 +135,7 @@ public List getLogFragments() { initialPackageVersions.put("javax.package6", "6.0.0"); initialPackageVersions.put("javax.package7", "7.0.0"); - finalPackageVersions = new HashMap(8); + finalPackageVersions = new HashMap<>(8); finalPackageVersions.put("jakarta.package0", "0.0.1"); finalPackageVersions.put("jakarta.package11", "1.1.1"); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiText.java b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiText.java index c07f56ff..c3299d45 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiText.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestTransformerMultiText.java @@ -75,28 +75,21 @@ public String getDynamicContentDir() { // Rules data ... - public static class TextRulesData { - public final String fileName; - public final String[] assignments; - - public TextRulesData(String fileName, String... assignments) { - this.fileName = fileName; - this.assignments = assignments; - } + public record TextRulesData(String fileName, String... assignments) { public void write(String propertiesDir) throws IOException { - try ( OutputStream outputStream = new FileOutputStream(propertiesDir + '/' + fileName, false) ) { // truncate - OutputStreamWriter outputWriter = new OutputStreamWriter(outputStream); + try (OutputStream outputStream = new FileOutputStream(propertiesDir + '/' + fileName(), false)) { // truncate + OutputStreamWriter outputWriter = new OutputStreamWriter(outputStream); - for ( String assignment : assignments ) { - outputWriter.write(assignment); - outputWriter.write('\n'); - } + for (String assignment : assignments()) { + outputWriter.write(assignment); + outputWriter.write('\n'); + } - outputWriter.flush(); + outputWriter.flush(); + } } } - } public static final String TIER0_MASTER_PROPERTIES = "tier0.master.properties"; public static final String TIER1_MASTER_PROPERTIES = "tier1.master.properties"; @@ -155,7 +148,7 @@ protected static String getInputName(int fileNo, int extNo) { public static final Map OUTPUT_TEXT_MAP; static { - Map outputMap = new HashMap(); + Map outputMap = new HashMap<>(); outputMap.put(".ext0", "The slow brown fox jumps over the happy dog."); outputMap.put(".ext3", INPUT_TEXT); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/TestUtils.java b/org.eclipse.transformer/src/test/java/transformer/test/TestUtils.java index fb35d56f..0caaa6a7 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/TestUtils.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/TestUtils.java @@ -184,14 +184,14 @@ public static List manifestCollapse(List inputManifestLines) { outputBuilder.append(inputLine.charAt(charNo)); } } else { - if (outputBuilder.length() > 0) { + if (!outputBuilder.isEmpty()) { outputManifestLines.add(outputBuilder.toString()); outputBuilder.setLength(0); } outputBuilder.append(inputLine); } } - if (outputBuilder.length() > 0) { + if (!outputBuilder.isEmpty()) { outputManifestLines.add(outputBuilder.toString()); outputBuilder.setLength(0); } @@ -224,7 +224,7 @@ public static Map loadPackageVersions( manifest.read(manifestStream); } - Map packageData = new HashMap(); + Map packageData = new HashMap<>(); String targetAttribute = manifest.getMainAttributes().getValue(attributeName); System.out.println(description + " [ " + manifestPath + " ]:"); @@ -263,7 +263,7 @@ public static void verifyPackageVersions( } public static List verifyPackageVersions(Map actual, Map expected) { - List errors = new ArrayList(); + List errors = new ArrayList<>(); for ( Map.Entry actualEntry : actual.entrySet() ) { String actualName = actualEntry.getKey(); @@ -332,7 +332,7 @@ public static void verifyLog(String description, List expectedFragments, */ public static List verifyLog(List expectedFragments, Collection logEvents) throws IOException { - List errors = new ArrayList(); + List errors = new ArrayList<>(); int expectedMatches = expectedFragments.size(); boolean[] matches = new boolean[expectedMatches]; @@ -413,7 +413,7 @@ public static List verifyOutputFiles( Map outputMap) throws IOException { - List errors = new ArrayList(); + List errors = new ArrayList<>(); for ( int fileNo = 0; fileNo < numFiles; fileNo++ ) { for ( int extNo = 0; extNo < numExts; extNo++ ) { @@ -488,7 +488,7 @@ public ErrorAccumulator(String name, int maxCount) { this.capacity = maxCount; this.size = 0; - this.errors = new ArrayList(maxCount); + this.errors = new ArrayList<>(maxCount); } /** @@ -556,14 +556,7 @@ public static ErrorAccumulator newErrors(String name) { // - public static class InputMapping { - public final File inputFile; - public final String entryName; - - public InputMapping(File inputFile, String entryName) { - this.inputFile = inputFile; - this.entryName = entryName; - } + public record InputMapping(File inputFile, String entryName) { } public static void zip(File sourceDir, File zipFile) throws IOException { @@ -617,13 +610,13 @@ public static void zip(File sourceDir, File zipFile, List inputMap if (inputMappings != null) { inputMappings.forEach(inputMapping -> { System.out.println( - "Zip entry [ " + inputMapping.inputFile.getPath() + " ] as [ " + inputMapping.entryName + " ]"); + "Zip entry [ " + inputMapping.inputFile().getPath() + " ] as [ " + inputMapping.entryName() + " ]"); - ZipEntry zipEntry = new ZipEntry(inputMapping.entryName); + ZipEntry zipEntry = new ZipEntry(inputMapping.entryName()); try { zip.putNextEntry(zipEntry); try { - IO.copy(inputMapping.inputFile, zip); + IO.copy(inputMapping.inputFile(), zip); } finally { zip.closeEntry(); } @@ -838,11 +831,7 @@ public static boolean compareDirectories( zipDirectories = listZipDirectories(zipFile); } catch ( IOException e ) { e.printStackTrace(); - if ( !errors.add("IOException listing actual [ " + zipPath + " ]") ) { - return false; - } else { - return true; - } + return errors.add("IOException listing actual [ " + zipPath + " ]"); } if ( (allowMissing != null) && !allowMissing.isEmpty() ) { @@ -857,11 +846,7 @@ public static boolean compareDirectories( expectedDirectories = listDirectories(expectedParent); } catch ( IOException e ) { e.printStackTrace(); - if ( !errors.add("IOException listing expected [ " + expectedPath + " ]") ) { - return false; - } else { - return true; - } + return errors.add("IOException listing expected [ " + expectedPath + " ]"); } expectedDirectories = convertSlashes(expectedDirectories); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/util/BiDiMapImpl.java b/org.eclipse.transformer/src/test/java/transformer/test/util/BiDiMapImpl.java index 4f2860e5..b80d4da4 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/util/BiDiMapImpl.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/util/BiDiMapImpl.java @@ -131,9 +131,9 @@ public boolean record(Holder holder, Held held) { boolean addedHolderToHeld = recordHeldToHolder(holder, held); if (addedHeldToHolder != addedHolderToHeld) { - System.out.println(String.format( - "[ %s ] Holder [ %s ] Held [ %s ] Added to holder [ %s ] Added to held [ %s ]", getHashText(), holder, - held, Boolean.valueOf(addedHeldToHolder), Boolean.valueOf(addedHolderToHeld))); + System.out.printf( + "[ %s ] Holder [ %s ] Held [ %s ] Added to holder [ %s ] Added to held [ %s ]%n", getHashText(), holder, + held, Boolean.valueOf(addedHeldToHolder), Boolean.valueOf(addedHolderToHeld)); } return addedHeldToHolder; @@ -150,20 +150,12 @@ protected boolean recordHeldToHolder(Holder holder, Held held) { } protected Set recordHolder(Holder holder) { - Set heldBy = holderToHeldMap.get(holder); - if (heldBy == null) { - heldBy = new HashSet<>(); - holderToHeldMap.put(holder, heldBy); - } + Set heldBy = holderToHeldMap.computeIfAbsent(holder, k -> new HashSet<>()); return heldBy; } protected Set recordHeld(Held held) { - Set holderOf = heldToHoldersMap.get(held); - if (holderOf == null) { - holderOf = new HashSet<>(); - heldToHoldersMap.put(held, holderOf); - } + Set holderOf = heldToHoldersMap.computeIfAbsent(held, k -> new HashSet<>()); return holderOf; } diff --git a/org.eclipse.transformer/src/test/java/transformer/test/util/CaptureLoggerImpl.java b/org.eclipse.transformer/src/test/java/transformer/test/util/CaptureLoggerImpl.java index 591b2bcd..e278b1a5 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/util/CaptureLoggerImpl.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/util/CaptureLoggerImpl.java @@ -47,20 +47,13 @@ public CaptureLoggerImpl(Logger baseLogger, boolean captureInactive) { public boolean isLoggable(Level level) { Logger useLogger = getBaseLogger(); - switch (level) { - case ERROR : - return useLogger.isErrorEnabled(); - case WARN : - return useLogger.isWarnEnabled(); - case INFO : - return useLogger.isInfoEnabled(); - case DEBUG : - return useLogger.isDebugEnabled(); - case TRACE : - return useLogger.isTraceEnabled(); - default : - throw new IllegalArgumentException("Unknown level [ " + level + " ]"); - } + return switch (level) { + case ERROR -> useLogger.isErrorEnabled(); + case WARN -> useLogger.isWarnEnabled(); + case INFO -> useLogger.isInfoEnabled(); + case DEBUG -> useLogger.isDebugEnabled(); + case TRACE -> useLogger.isTraceEnabled(); + }; } public Logger getBaseLogger() { diff --git a/org.eclipse.transformer/src/test/java/transformer/test/util/ClassData.java b/org.eclipse.transformer/src/test/java/transformer/test/util/ClassData.java index d4f2b624..831c9859 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/util/ClassData.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/util/ClassData.java @@ -17,6 +17,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -242,7 +243,7 @@ public void log(PrintWriter writer) { writer.println(logPrefix + "Class name: " + className); writer.println(logPrefix + "Superclass name: " + superclassName); - writer.println(logPrefix + "Interface names: " + interfaceNames); + writer.println(logPrefix + "Interface names: " + Arrays.toString(interfaceNames)); if (classAnnotationNames.isEmpty()) { writer.println(logPrefix + "Class annotations: ** EMPTY **"); diff --git a/org.eclipse.transformer/src/test/java/transformer/test/util/SetDeltaImpl.java b/org.eclipse.transformer/src/test/java/transformer/test/util/SetDeltaImpl.java index a63f0cae..e01b26ab 100644 --- a/org.eclipse.transformer/src/test/java/transformer/test/util/SetDeltaImpl.java +++ b/org.eclipse.transformer/src/test/java/transformer/test/util/SetDeltaImpl.java @@ -77,7 +77,7 @@ public String getHashText() { // protected final Set still_i; public Set getAdded() { - return ((added_f == null) ? null : added_f); + return added_f; } public boolean isNullAdded() { @@ -85,7 +85,7 @@ public boolean isNullAdded() { } public Set getRemoved() { - return ((removed_i == null) ? null : removed_i); + return removed_i; } public boolean isNullRemoved() { @@ -93,7 +93,7 @@ public boolean isNullRemoved() { } public Set getStill() { - return ((still_f == null) ? null : still_f); + return still_f; } public boolean isNullStill() {