Skip to content

Commit

Permalink
Javassist for Classes.sortDeclarativeOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
safris committed Sep 16, 2023
1 parent 4091abe commit c84b46e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
6 changes: 5 additions & 1 deletion binding/src/main/java/org/jsonx/JxEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ public boolean test(final Method method) {

@Override
void beforePut(final Method[] methods) {
Classes.sortDeclarativeOrder(methods);
try {
Classes.sortDeclarativeOrder(methods, true);
}
catch (final ClassNotFoundException e) {
}
}
};

Expand Down
7 changes: 6 additions & 1 deletion generator/src/main/java/org/jsonx/ObjectModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,12 @@ public boolean test(final Method method) {

@Override
void beforePut(final Method[] methods) {
Classes.sortDeclarativeOrder(methods);
try {
Classes.sortDeclarativeOrder(methods, true);
}
catch (final ClassNotFoundException e) {
System.err.println("Cannot sort methods in declarative order because Javassist is not present on the system classpath");
}
}
};

Expand Down
7 changes: 6 additions & 1 deletion jsonx-maven-plugin/src/test/java/org/jsonx/ClassTrial.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ public boolean test(final Method method) {

@Override
void beforePut(final Method[] methods) {
Classes.sortDeclarativeOrder(methods);
try {
Classes.sortDeclarativeOrder(methods, true);
}
catch (final ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
};

Expand Down
7 changes: 6 additions & 1 deletion jsonx-maven-plugin/src/test/java/org/jsonx/ObjectTrial.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ public boolean test(final Method method) {

@Override
void beforePut(final Method[] methods) {
Classes.sortDeclarativeOrder(methods);
try {
Classes.sortDeclarativeOrder(methods, true);
}
catch (final ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
};

Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,11 @@
<version>0.7.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

0 comments on commit c84b46e

Please sign in to comment.