Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace com.sun.xml.internal.bind.* packages with com.sun.xml.bind.* packages #508

Merged
merged 10 commits into from
Jul 12, 2024
20 changes: 17 additions & 3 deletions src/main/resources/META-INF/rewrite/java-version-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ recipeList:
- org.openrewrite.java.migrate.cobertura.RemoveCoberturaMavenPlugin
- org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion
- org.openrewrite.java.migrate.UpgradeBuildToJava11
# Disabled due to null safety issues in the current implementation
# https://github.com/openrewrite/rewrite-migrate-java/issues/250
# - org.openrewrite.java.migrate.util.JavaUtilAPIs
# Disabled due to null safety issues in the current implementation
# https://github.com/openrewrite/rewrite-migrate-java/issues/250
# - org.openrewrite.java.migrate.util.JavaUtilAPIs
timtebeek marked this conversation as resolved.
Show resolved Hide resolved
- org.openrewrite.java.migrate.util.OptionalNotPresentToIsEmpty
- org.openrewrite.java.migrate.util.OptionalNotEmptyToIsPresent
- org.openrewrite.java.migrate.util.OptionalStreamRecipe
Expand All @@ -69,6 +69,8 @@ recipeList:
- org.openrewrite.java.migrate.RemovedPolicy
- org.openrewrite.java.migrate.ReferenceCloneMethod
- org.openrewrite.java.migrate.ThreadStopDestroy
- org.openrewrite.java.migrate.InternalBindPackages

---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.UpgradeBuildToJava11
Expand Down Expand Up @@ -264,3 +266,15 @@ recipeList:
methodPattern: java.lang.Thread destroy()
- org.openrewrite.java.migrate.RemoveMethodInvocation:
methodPattern: java.lang.Thread stop(java.lang.Throwable)
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.InternalBindPackages
displayName: Use `com.sun.xml.bind.*` instead of `com.sun.xml.internal.bind.*`
description: Do not use APIs from `com.sun.xml.internal.bind.*` packages.
tags:
- java11
recipeList:
- org.openrewrite.java.ChangePackage:
oldPackageName: com.sun.xml.internal.bind
newPackageName: com.sun.xml.bind
recursive: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright 2024 the original author or authors.
* <p>
* 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.
*/
package org.openrewrite.java.migrate;
BhavanaPidapa marked this conversation as resolved.
Show resolved Hide resolved

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.java.Assertions.javaVersion;

class InternalBindPackages implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec
.parser(JavaParser.fromJavaVersion()
.classpathFromResources(new InMemoryExecutionContext(), "sun.internal.newClass"))
.recipeFromResources("org.openrewrite.java.migrate.InternalBindPackages");
}

@Test
@DocumentExample
void internalBindPackages() {
rewriteRun(
//language=java
java("""
timtebeek marked this conversation as resolved.
Show resolved Hide resolved
package com.ibm.test;
public class TestInternalBindPackages {
public void testInternalBindPackages() {
com.sun.xml.internal.bind.v2.WellKnownNamespace namespace = null;
namespace.hashCode();
com.sun.xml.internal.bind.v2.ContextFactory contextFactory = null;
contextFactory.hashCode();
}
}
""",
"""
package com.ibm.test;
public class TestInternalBindPackages {
public void testInternalBindPackages() {
com.sun.xml.bind.v2.WellKnownNamespace namespace = null;
namespace.hashCode();
com.sun.xml.bind.v2.ContextFactory contextFactory = null;
contextFactory.hashCode();
}
}
"""
)
);
}
}
Binary file not shown.
Loading