You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2019/03/24 13:42:21 UTC
[juneau] branch master updated: Revert default method/field sorting
behavior to 8.0.0.
This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 1bd3d8b Revert default method/field sorting behavior to 8.0.0.
1bd3d8b is described below
commit 1bd3d8be0ed8a51a0a68ccef2d1d6778baa4b6ee
Author: JamesBognar <ja...@apache.org>
AuthorDate: Sun Mar 24 09:42:00 2019 -0400
Revert default method/field sorting behavior to 8.0.0.
---
.../org/apache/juneau/json/JsonParserTest.java | 26 +++++------
.../org/apache/juneau/reflection/ClassInfo.java | 53 +++++++++++++++-------
2 files changed, 50 insertions(+), 29 deletions(-)
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonParserTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonParserTest.java
index 9fcda5d..b7ee759 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonParserTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/json/JsonParserTest.java
@@ -186,25 +186,25 @@ public class JsonParserTest {
ReaderParser p = JsonParser.DEFAULT;
WriterSerializer s = SimpleJsonSerializer.DEFAULT;
- json = "{f1:'1',f10:'1',f2:'1',f3:'true',f4:'true',f5:'1',f6:'1',f7:'1',f8:'1',f9:'1'}";
+ json = "{f01:'1',f02:'1',f03:'true',f04:'true',f05:'1',f06:'1',f07:'1',f08:'1',f09:'1',f10:'1'}";
B b = p.parse(json, B.class);
- assertEquals("{f1:1,f10:1,f2:1,f3:true,f4:true,f5:1.0,f6:1.0,f7:1,f8:1,f9:1}", s.toString(b));
+ assertEquals("{f01:1,f02:1,f03:true,f04:true,f05:1.0,f06:1.0,f07:1,f08:1,f09:1,f10:1}", s.toString(b));
- json = "{f1:'',f2:'',f3:'',f4:'',f5:'',f6:'',f7:'',f8:'',f9:'',f10:''}";
+ json = "{f01:'',f02:'',f03:'',f04:'',f05:'',f06:'',f07:'',f08:'',f09:'',f10:''}";
b = p.parse(json, B.class);
- assertEquals("{f1:0,f10:0,f2:0,f3:false,f4:false,f5:0.0,f6:0.0,f7:0,f8:0,f9:0}", s.toString(b));
+ assertEquals("{f01:0,f02:0,f03:false,f04:false,f05:0.0,f06:0.0,f07:0,f08:0,f09:0,f10:0}", s.toString(b));
}
public static class B {
- public int f1;
- public Integer f2;
- public boolean f3;
- public Boolean f4;
- public float f5;
- public Float f6;
- public long f7;
- public Long f8;
- public byte f9;
+ public int f01;
+ public Integer f02;
+ public boolean f03;
+ public Boolean f04;
+ public float f05;
+ public Float f06;
+ public long f07;
+ public Long f08;
+ public byte f09;
public Byte f10;
}
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflection/ClassInfo.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflection/ClassInfo.java
index 880142e..19f5aec 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflection/ClassInfo.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/reflection/ClassInfo.java
@@ -172,19 +172,22 @@ public final class ClassInfo {
* Returns all declared methods on this class and all parent classes in child-to-parent order.
*
* <p>
- * Methods are sorted alphabetically per class before being aggregated.
+ * Methods are ordered per the natural ordering of the underlying JVM.
+ * <br>Some JVMs (IBM) preserve the declaration order of methods. Other JVMs (Oracle) do not and return them in random order.
*
* @return All declared methods on this class and all parent classes in child-to-parent order.
*/
public Iterable<MethodInfo> getAllMethods() {
- return getAllMethods(false, true);
+ return getAllMethods(false, false);
}
/**
* Returns all declared methods on this class and all parent classes in child-to-parent order.
*
* @param parentFirst If <jk>true</jk>, methods on parent classes are listed first.
- * @param sort If <jk>true</jk>, methods are sorted alphabetically per class.
+ * @param sort
+ * If <jk>true</jk>, methods are sorted alphabetically per class.
+ * Otherwise, uses the order of the methods in the underlying JVM.
* @return All declared methods on this class and all parent classes.
*/
public Iterable<MethodInfo> getAllMethods(boolean parentFirst, boolean sort) {
@@ -193,17 +196,23 @@ public final class ClassInfo {
/**
* Returns all methods declared on this class.
+ *
+ * <p>
+ * Methods are ordered per the natural ordering of the underlying JVM.
+ * <br>Some JVMs (IBM) preserve the declaration order of methods. Other JVMs (Oracle) do not and return them in random order.
*
- * @return All methods declared on this class in alphabetical order.
+ * @return All methods declared on this class.
*/
public Iterable<MethodInfo> getDeclaredMethods() {
- return getDeclaredMethods(true);
+ return getDeclaredMethods(false);
}
/**
* Returns all methods declared on this class.
*
- * @param sort If <jk>true</jk>, sorts the results in alphabetical order.
+ * @param sort
+ * If <jk>true</jk>, methods are sorted alphabetically.
+ * Otherwise, uses the order of the methods in the underlying JVM.
* @return All methods declared on this class.
*/
public Iterable<MethodInfo> getDeclaredMethods(boolean sort) {
@@ -225,7 +234,9 @@ public final class ClassInfo {
/**
* Returns all public methods on this class.
*
- * @param sort If <jk>true</jk>, sorts methods in alphabetical order.
+ * @param sort
+ * If <jk>true</jk>, methods are sorted alphabetically.
+ * Otherwise, uses the order of the methods in the underlying JVM.
* @return All public methods on this class.
*/
public Iterable<MethodInfo> getPublicMethods(boolean sort) {
@@ -377,19 +388,22 @@ public final class ClassInfo {
* Returns all field on this class and all parent classes in child-to-parent order.
*
* <p>
- * Fields are sorted alphabetically per class before being aggregated.
+ * Fields are ordered per the natural ordering of the underlying JVM.
+ * <br>Some JVMs (IBM) preserve the declaration order of fields. Other JVMs (Oracle) do not and return them in random order.
*
* @return All declared methods on this class and all parent classes in child-to-parent order.
*/
public Iterable<FieldInfo> getAllFields() {
- return getAllFields(false, true);
+ return getAllFields(false, false);
}
/**
* Returns all field on this class and all parent classes.
*
* @param parentFirst If <jk>true</jk>, fields are listed in parent-to-child order.
- * @param sort If <jk>true</jk>, fields are sorted alphabetically within each class.
+ * @param sort
+ * If <jk>true</jk>, fields are sorted alphabetically.
+ * Otherwise, uses the order of the fields in the underlying JVM.
* @return All declared methods on this class and all parent classes.
*/
public Iterable<FieldInfo> getAllFields(boolean parentFirst, boolean sort) {
@@ -400,27 +414,34 @@ public final class ClassInfo {
* Returns all field on this class and all parent classes in parent-to-child order.
*
* <p>
- * Fields are sorted alphabetically per class before being aggregated.
+ * Fields are ordered per the natural ordering of the underlying JVM.
+ * <br>Some JVMs (IBM) preserve the declaration order of fields. Other JVMs (Oracle) do not and return them in random order.
*
* @return All declared methods on this class and all parent classes in parent-to-child order.
*/
public Iterable<FieldInfo> getAllFieldsParentFirst() {
- return getAllFields(true, true);
+ return getAllFields(true, false);
}
/**
* Returns all fields declared on this class.
- *
- * @return All fields declared on this class in alphabetical order.
+ *
+ * <p>
+ * Fields are ordered per the natural ordering of the underlying JVM.
+ * <br>Some JVMs (IBM) preserve the declaration order of fields. Other JVMs (Oracle) do not and return them in random order.
+ *
+ * @return All fields declared on this class.
*/
public Iterable<FieldInfo> getDeclaredFields() {
- return getDeclaredFields(true);
+ return getDeclaredFields(false);
}
/**
* Returns all fields declared on this class.
*
- * @param sort If <jk>true</jk>, fields are listed in alphabetical order.
+ * @param sort
+ * If <jk>true</jk>, fields are sorted alphabetically.
+ * Otherwise, uses the order of the fields in the underlying JVM.
* @return All fields declared on this class.
*/
public Iterable<FieldInfo> getDeclaredFields(boolean sort) {