Skip to content

Commit

Permalink
Fixup of initial jt-264-basics merge PR #282
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent SCHOELENS committed Aug 4, 2023
1 parent ecc6839 commit dc1e879
Show file tree
Hide file tree
Showing 108 changed files with 414 additions and 330 deletions.
6 changes: 3 additions & 3 deletions basics/ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics-ant</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Ant Task</name>
<name>JAXB Tools :: JAXB Basics :: Ant Task</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
Expand Down
20 changes: 10 additions & 10 deletions basics/basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Basic Plugins</name>
<name>JAXB Tools :: JAXB Basics :: Basic Plugins</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
</dependency>
<dependency>
Expand All @@ -32,8 +32,8 @@
<artifactId>javaparser</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin-testing</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -78,13 +78,13 @@
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.jvnet.jaxb2.maven2
org.jvnet.jaxb
</groupId>
<artifactId>
maven-jaxb2-plugin
jaxb-maven-plugin
</artifactId>
<versionRange>
[0.8.1,)
[2.0.0,)
</versionRange>
<goals>
<goal>generate</goal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
import org.jvnet.jaxb.maven.AbstractXJC2Mojo;
import org.jvnet.jaxb.maven.test.RunXJC2Mojo;

public class RunCopyablePlugin extends RunXJC2Mojo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
import org.jvnet.jaxb.maven.AbstractXJC2Mojo;
import org.jvnet.jaxb.maven.test.RunXJC2Mojo;

public class RunEqualsPlugin extends RunXJC2Mojo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
import org.jvnet.jaxb.maven.AbstractXJC2Mojo;
import org.jvnet.jaxb.maven.test.RunXJC2Mojo;

public class RunMergeablePlugin extends RunXJC2Mojo {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.ArrayList;
import java.util.List;

import org.jvnet.jaxb2.maven2.AbstractXJC2Mojo;
import org.jvnet.jaxb2.maven2.test.RunXJC2Mojo;
import org.jvnet.jaxb.maven.AbstractXJC2Mojo;
import org.jvnet.jaxb.maven.test.RunXJC2Mojo;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;

public class RunToStringPlugin extends RunXJC2Mojo {
Expand Down
8 changes: 4 additions & 4 deletions basics/dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-dist</artifactId>
<packaging>pom</packaging>
<name>JAXB2 Basics - Distribution</name>
<name>JAXB Tools :: JAXB Basics :: Distribution</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
Expand Down
12 changes: 6 additions & 6 deletions basics/plugins/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics-plugins</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Full Plugins JAR</name>
<name>JAXB Tools :: JAXB Basics :: Full Plugins JAR</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
</dependency>
<dependency>
Expand Down
14 changes: 7 additions & 7 deletions basics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>jaxb-basics-project</artifactId>
<packaging>pom</packaging>
<name>JAXB2 Basics - Project</name>
<name>JAXB Tools :: JAXB Basics :: Project</name>
<description>JAXB Basics is a part of JAXB Tools project which implements plugins and tools for JAXB implementation.</description>
<modules>
<module>ant</module>
Expand Down Expand Up @@ -65,32 +65,32 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-plugins</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-ant</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-testing</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${project.version}</version>
</dependency>
Expand Down
6 changes: 3 additions & 3 deletions basics/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics-runtime</artifactId>
<packaging>jar</packaging>
<name>JAXB2 Basics - Runtime</name>
<name>JAXB Tools :: JAXB Basics :: Runtime</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-project</artifactId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-basics-project</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ protected Object copyInternal(ObjectLocator locator, Cloneable object) {

return method.invoke(object, (Object[]) null);
} catch (Exception ex) {
if ("java.lang.reflect.InaccessibleObjectException".equals(ex.getClass().getName())) {
return copyInternalJdk11(locator, object);
}
throw new UnsupportedOperationException(
"Could not clone the object ["
+ object
Expand All @@ -267,6 +270,74 @@ protected Object copyInternal(ObjectLocator locator, Cloneable object) {
}
}
}
protected Object copyInternalJdk11(ObjectLocator locator, Cloneable object) {
Class<?> clazz = object.getClass();
Class<?> parentClazz = clazz.getSuperclass();
Method method = null;

while (parentClazz != null && hasCloneableInterface(parentClazz)) {
clazz = parentClazz;
parentClazz = clazz.getSuperclass();
}

try {
method = clazz.getMethod("clone", (Class[]) null);
} catch (NoSuchMethodException nsmex) {
method = null;
}

if (method == null || !Modifier.isPublic(method.getModifiers())) {

throw new UnsupportedOperationException(
"Could not clone object [" + object + "].",
new CloneNotSupportedException(
"Object class ["
+ object.getClass()
+ "] implements java.lang.Cloneable interface, "
+ "with final determined class ["
+ clazz
+ "] but does not provide a public no-arg clone() method. "
+ "By convention, classes that implement java.lang.Cloneable "
+ "should override java.lang.Object.clone() method (which is protected) "
+ "with a public method."));
}

boolean wasAccessible = method.isAccessible();
try {
if (!wasAccessible) {
try {
method.setAccessible(true);
} catch (SecurityException ignore) {
}
}

return method.invoke(object, (Object[]) null);
} catch (Exception ex) {
throw new UnsupportedOperationException(
"Could not clone (jdk11) the object ["
+ object
+ "] as invocation of the clone() method has thrown an exception.",
ex);
} finally {
if (!wasAccessible) {
try {
method.setAccessible(false);
} catch (SecurityException ignore) {
}
}
}
}

private static boolean hasCloneableInterface(Class<?> clazz) {
if (clazz != null) {
for (Class<?> iface : clazz.getInterfaces()) {
if (iface.isAssignableFrom(Cloneable.class)) {
return true;
}
}
}
return false;
}

@Override
public Boolean shouldBeCopiedAndSet(ObjectLocator locator, boolean valueSet) {
Expand Down
10 changes: 5 additions & 5 deletions basics/samples/basic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>jaxb2-basics-sample-basic</artifactId>
<packaging>pom</packaging>
<name>JAXB2 Basics - Sample [basic]</name>
<name>JAXB Tools :: JAXB Basics :: Sample [basic]</name>
<parent>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-samples</artifactId>
<version>2.0.4-SNAPSHOT</version>
</parent>
Expand All @@ -16,15 +16,15 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-plugins</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-testing</artifactId>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-ant</artifactId>
</dependency>
<dependency>
Expand Down
12 changes: 6 additions & 6 deletions basics/samples/basic/project-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics-testing</artifactId>
<version>${project.version}</version>
<scope>test</scope>
Expand All @@ -42,9 +42,9 @@
<defaultGoal>test</defaultGoal>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb-maven-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -63,7 +63,7 @@
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<groupId>org.jvnet.jaxb</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${project.version}</version>
</plugin>
Expand Down
Loading

0 comments on commit dc1e879

Please sign in to comment.