The following issues were found

src/test/java/com/alibaba/json/test/a/A20170327_0.java
15 issues
Avoid throwing raw exception types.
Design

Line: 61

                          } else if (object instanceof String) {
                moneyCentStr = (String) object;
            } else {
                throw new RuntimeException("money属性反序列化失败,不支持的类型:" + object.getClass().getName());
            }
            if (moneyCentStr.length() != 0) {
                Money m = new Money();
                m.cent = Long.valueOf(moneyCentStr);
                return (T) m;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 19

               * Created by wenshao on 27/03/2017.
 */
public class A20170327_0 extends TestCase {
    public void test_0() throws Exception {
        String s = "{\"itemCurrentAmount\":{\"amount\":12.50,\"cent\":1250,\"centFactor\":100,\"currency\":\"CNY\",\"currencyCode\":\"CNY\"},\"itemDiscountAmount\":{\"$ref\":\"$.itemCurrentAmount\"}}";
        //String s = "{\"itemDiscountAmount\":{\"$ref\":\"$.itemCurrentAmount\"},\"itemCurrentAmount\":{\"amount\":12.50,\"cent\":1250,\"centFactor\":100,\"currency\":\"CNY\",\"currencyCode\":\"CNY\"}}";

        ParserConfig config = new ParserConfig();
        config.putDeserializer(Money.class, new MoneyDeserialize());

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      config.putDeserializer(Money.class, new MoneyDeserialize());

        Model model = JSON.parseObject(s, Model.class, config);
        assertSame(model.itemCurrentAmount, model.itemDiscountAmount);
        //JSONObject jsonObject = (JSONObject) JSON.parse(s);
        //assertSame(jsonObject.get("itemCurrentAmount"), jsonObject.get("itemDiscountAmount"));
    }

    public static class Model {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 33

                  }

    public static class Model {
        public Money itemCurrentAmount;
        public Money itemDiscountAmount;
    }

    public static class Money {
        public BigDecimal amount;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 34

              
    public static class Model {
        public Money itemCurrentAmount;
        public Money itemDiscountAmount;
    }

    public static class Money {
        public BigDecimal amount;
        public long cent;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 39

              
    public static class Money {
        public BigDecimal amount;
        public long cent;
        public int centFactor;
        public String currency;
        public String currencyCode;
    }


            

Reported by PMD.

Avoid unused local variables such as 'cxt'.
Design

Line: 49

              
        @SuppressWarnings("unchecked")
        public <T> T deserialze(DefaultJSONParser parser, Type type, Object fieldName) {
            ParseContext cxt = parser.getContext();
            Object object = parser.parse(fieldName);
            if (object == null) {
                return null;
            }
            String moneyCentStr = null;

            

Reported by PMD.

The initializer for variable 'moneyCentStr' is never used (overwritten on lines 57 and 59)
Design

Line: 54

                          if (object == null) {
                return null;
            }
            String moneyCentStr = null;
            if (object instanceof JSONObject) {//历史数据兼容
                JSONObject jsonObject = (JSONObject) object;
                moneyCentStr = jsonObject.getString("cent");
            } else if (object instanceof String) {
                moneyCentStr = (String) object;

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 57

                          String moneyCentStr = null;
            if (object instanceof JSONObject) {//历史数据兼容
                JSONObject jsonObject = (JSONObject) object;
                moneyCentStr = jsonObject.getString("cent");
            } else if (object instanceof String) {
                moneyCentStr = (String) object;
            } else {
                throw new RuntimeException("money属性反序列化失败,不支持的类型:" + object.getClass().getName());
            }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 61

                          } else if (object instanceof String) {
                moneyCentStr = (String) object;
            } else {
                throw new RuntimeException("money属性反序列化失败,不支持的类型:" + object.getClass().getName());
            }
            if (moneyCentStr.length() != 0) {
                Money m = new Money();
                m.cent = Long.valueOf(moneyCentStr);
                return (T) m;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/AbstractSerializeTest.java
15 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 12

              import com.alibaba.fastjson.parser.deserializer.ObjectDeserializer;

public class AbstractSerializeTest extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");

        ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
        ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 13

              
public class AbstractSerializeTest extends TestCase {
    protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");

        ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
        ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 15

                  protected void setUp() throws Exception {
        ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");

        ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
        ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 16

                      ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.AbstractSerializeTest");

        ObjectDeserializer serializerB = ParserConfig.getGlobalInstance().getDeserializer(B.class);
        ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 19

                      ParserConfig.getGlobalInstance().putDeserializer(A.class, serializerB);
    }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 20

                  }

    protected void tearDown() throws Exception {
        ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 23

                      ParserConfig.getGlobalInstance().putDeserializer(A.class, null);
    }

    public void test_mapping_0() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\"}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
    }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 30

                      Assert.assertNotNull(b);
    }

    public void test_mapping_1() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":123}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(123, b.getId());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 35

              
        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(123, b.getId());
    }

    public void test_mapping_2() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":234,\"name\":\"abc\"}";


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 38

                      Assert.assertEquals(123, b.getId());
    }

    public void test_mapping_2() throws Exception {
        String text = "{\"@type\":\"com.alibaba.json.bvt.parser.deser.AbstractSerializeTest$A\",\"id\":234,\"name\":\"abc\"}";

        B b = (B) JSON.parse(text);
        Assert.assertNotNull(b);
        Assert.assertEquals(234, b.getId());

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/JavaBeanSerializerTest.java
15 issues
Avoid throwing raw exception types.
Design

Line: 156

                  public static class C {

        public List<String> getL0() {
            throw new RuntimeException();
        }

        public void setL0(List<String> l0) {
        }
    }

            

Reported by PMD.

Avoid throwing raw exception types.
Design

Line: 166

                  public static class D {

        public Collection<String> getL0() {
            throw new RuntimeException();
        }
    }

    public static class E {


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 18

              
public class JavaBeanSerializerTest extends TestCase {

    public void test_0_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        A a = new A();
        a.getL0().add("A");
        a.getL0().add("B");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 22

                      SerializeWriter out = new SerializeWriter();

        A a = new A();
        a.getL0().add("A");
        a.getL0().add("B");

        JavaBeanSerializer serializer = new JavaBeanSerializer(A.class);
        serializer.write(new JSONSerializer(out), a, null, null, 0);


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 23

              
        A a = new A();
        a.getL0().add("A");
        a.getL0().add("B");

        JavaBeanSerializer serializer = new JavaBeanSerializer(A.class);
        serializer.write(new JSONSerializer(out), a, null, null, 0);

        Assert.assertEquals("{\"l0\":[\"A\",\"B\"]}", out.toString());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 31

                      Assert.assertEquals("{\"l0\":[\"A\",\"B\"]}", out.toString());
    }

    public void test_1_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        B a = new B();
        a.getL0().add("A");
        a.getL0().add("B");

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 35

                      SerializeWriter out = new SerializeWriter();

        B a = new B();
        a.getL0().add("A");
        a.getL0().add("B");

        JavaBeanSerializer serializer = new JavaBeanSerializer(B.class);
        serializer.write(new JSONSerializer(out), a, null, null, 0);


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 36

              
        B a = new B();
        a.getL0().add("A");
        a.getL0().add("B");

        JavaBeanSerializer serializer = new JavaBeanSerializer(B.class);
        serializer.write(new JSONSerializer(out), a, null, null, 0);

        Assert.assertEquals("{\"l0\":[\"A\",\"B\"],\"l1\":[]}", out.toString());

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 44

                      Assert.assertEquals("{\"l0\":[\"A\",\"B\"],\"l1\":[]}", out.toString());
    }

    public void test_2_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        JavaBeanSerializer serializer = new JavaBeanSerializer(F.class);
        serializer.write(new JSONSerializer(out), new F(new E(123)), null, null, 0);


            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 53

                      Assert.assertEquals("{\"e\":{\"id\":123}}", out.toString());
    }

    public void test_3_s() throws Exception {
        SerializeWriter out = new SerializeWriter();

        JavaBeanSerializer serializer = new JavaBeanSerializer(F.class);
        serializer.write(new JSONSerializer(out), new F(null), null, null, 0);


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_for_wangran2.java
15 issues
System.out.println is used
Design

Line: 47

                      }

        public void setSecond(Child second) {
            System.out.println("setSecond");
            this.second = second;
        }

        public Child getFirst() {
            return first;

            

Reported by PMD.

System.out.println is used
Design

Line: 56

                      }

        public void setFirst(Child first) {
            System.out.println("setFirst");
            this.first = first;
        }

        public List<Child> getChildren() {
            return children;

            

Reported by PMD.

System.out.println is used
Design

Line: 65

                      }

        public void setChildren(List<Child> children) {
            System.out.println("setChildren");
            this.children = children;
        }

        public int getId() {
            return id;

            

Reported by PMD.

System.out.println is used
Design

Line: 102

                      }

        public void setRoot(Root root) {
            System.out.println("setRoot");
            this.root = root;
        }

        public int getId() {
            return id;

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 13

              
public class Bug_for_wangran2 extends TestCase {

    public void test_for_wangran() throws Exception {
        String text = "{" + //
                      "\"first\":{\"id\":1001}," + //
                      "\"second\":{\"id\":1002,\"root\":{\"$ref\":\"$\"}}," + //
                      "\"id\":23," + //
                      "\"name\":\"xxx\"," + //

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 22

                                    "\"children\":[{\"root\":{\"$ref\":\"$\"}},{\"$ref\":\"$.second\"}]" + //
                      "}";
        Root root = JSON.parseObject(text, Root.class);
        Assert.assertEquals(23, root.getId());
        Assert.assertEquals("xxx", root.getName());
        Assert.assertTrue(root == root.getChildren().get(0).getRoot());
        Assert.assertTrue(root == root.getChildren().get(1).getRoot());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 23

                                    "}";
        Root root = JSON.parseObject(text, Root.class);
        Assert.assertEquals(23, root.getId());
        Assert.assertEquals("xxx", root.getName());
        Assert.assertTrue(root == root.getChildren().get(0).getRoot());
        Assert.assertTrue(root == root.getChildren().get(1).getRoot());
    }

    public static class Root {

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 24

                      Root root = JSON.parseObject(text, Root.class);
        Assert.assertEquals(23, root.getId());
        Assert.assertEquals("xxx", root.getName());
        Assert.assertTrue(root == root.getChildren().get(0).getRoot());
        Assert.assertTrue(root == root.getChildren().get(1).getRoot());
    }

    public static class Root {


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 24

                      Root root = JSON.parseObject(text, Root.class);
        Assert.assertEquals(23, root.getId());
        Assert.assertEquals("xxx", root.getName());
        Assert.assertTrue(root == root.getChildren().get(0).getRoot());
        Assert.assertTrue(root == root.getChildren().get(1).getRoot());
    }

    public static class Root {


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 24

                      Root root = JSON.parseObject(text, Root.class);
        Assert.assertEquals(23, root.getId());
        Assert.assertEquals("xxx", root.getName());
        Assert.assertTrue(root == root.getChildren().get(0).getRoot());
        Assert.assertTrue(root == root.getChildren().get(1).getRoot());
    }

    public static class Root {


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/array/FieldBoolArrayTest.java
15 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 10

               * Created by wenshao on 11/01/2017.
 */
public class FieldBoolArrayTest extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 10

               * Created by wenshao on 11/01/2017.
 */
public class FieldBoolArrayTest extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 12

              public class FieldBoolArrayTest extends TestCase {
    public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

                  public void test_intArray() throws Exception {
        Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);

            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 14

                      Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                      Model model = JSON.parseObject("{\"value\":[1,null,true,false,0]}", Model.class);
        assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 15

                      assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }


            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 15

                      assertNotNull(model.value);
        assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }


            

Reported by PMD.

Use assertTrue(x)/assertFalse(x) instead of assertEquals(true, x)/assertEquals(false, x) or assertEquals(Boolean.TRUE, x)/assertEquals(Boolean.FALSE, x).
Design

Line: 16

                      assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

                      assertEquals(5, model.value.length);
        assertEquals(true, model.value[0]);
        assertEquals(false, model.value[1]);
        assertEquals(true, model.value[2]);
        assertEquals(false, model.value[3]);
        assertEquals(false, model.value[4]);
    }

    public static class Model {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/JSONArrayTest2.java
15 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 13

              
public class JSONArrayTest2 extends TestCase {

    public void test_0() throws Exception {
        long time = System.currentTimeMillis();
        JSONArray array = new JSONArray();
        array.add(null);
        array.add(1);
        array.add(time);

            

Reported by PMD.

Dont create instances of already existing BigInteger and BigDecimal (ZERO, ONE, TEN)
Performance

Line: 23

                      Assert.assertEquals(0, array.getShortValue(0));
        Assert.assertTrue(0F == array.getFloatValue(0));
        Assert.assertTrue(0D == array.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array.getBigInteger(1));
        Assert.assertEquals("1", array.getString(1));
        Assert.assertEquals(new java.util.Date(time), array.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array.getTimestamp(2));


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 30

                      Assert.assertEquals(new java.sql.Timestamp(time), array.getTimestamp(2));

        JSONArray array2 = (JSONArray) array.clone();
        Assert.assertEquals(0, array2.getByteValue(0));
        Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 31

              
        JSONArray array2 = (JSONArray) array.clone();
        Assert.assertEquals(0, array2.getByteValue(0));
        Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 32

                      JSONArray array2 = (JSONArray) array.clone();
        Assert.assertEquals(0, array2.getByteValue(0));
        Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 33

                      Assert.assertEquals(0, array2.getByteValue(0));
        Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array2.getTimestamp(2));

            

Reported by PMD.

Dont create instances of already existing BigInteger and BigDecimal (ZERO, ONE, TEN)
Performance

Line: 34

                      Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array2.getTimestamp(2));
        Assert.assertEquals(array2.size(), array2.size());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 34

                      Assert.assertEquals(0, array2.getShortValue(0));
        Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array2.getTimestamp(2));
        Assert.assertEquals(array2.size(), array2.size());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 35

                      Assert.assertTrue(0F == array2.getFloatValue(0));
        Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array2.getTimestamp(2));
        Assert.assertEquals(array2.size(), array2.size());


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 36

                      Assert.assertTrue(0D == array2.getDoubleValue(0));
        Assert.assertEquals(new BigInteger("1"), array2.getBigInteger(1));
        Assert.assertEquals("1", array2.getString(1));
        Assert.assertEquals(new java.util.Date(time), array2.getDate(2));
        Assert.assertEquals(new java.sql.Date(time), array2.getSqlDate(2));
        Assert.assertEquals(new java.sql.Timestamp(time), array2.getTimestamp(2));
        Assert.assertEquals(array2.size(), array2.size());

    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Issue585.java
15 issues
Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 16

              import junit.framework.TestCase;

public class Issue585 extends TestCase {
    private String original = JSON.DEFAULT_TYPE_KEY;
    private ParserConfig originalConfig = ParserConfig.global;

    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {

            

Reported by PMD.

Private field 'original' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 16

              import junit.framework.TestCase;

public class Issue585 extends TestCase {
    private String original = JSON.DEFAULT_TYPE_KEY;
    private ParserConfig originalConfig = ParserConfig.global;

    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 17

              
public class Issue585 extends TestCase {
    private String original = JSON.DEFAULT_TYPE_KEY;
    private ParserConfig originalConfig = ParserConfig.global;

    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");

            

Reported by PMD.

Private field 'originalConfig' could be made final; it is only initialized in the declaration or constructor.
Design

Line: 17

              
public class Issue585 extends TestCase {
    private String original = JSON.DEFAULT_TYPE_KEY;
    private ParserConfig originalConfig = ParserConfig.global;

    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 19

                  private String original = JSON.DEFAULT_TYPE_KEY;
    private ParserConfig originalConfig = ParserConfig.global;

    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");
        }


            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 21

              
    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");
        }

        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
    }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 21

              
    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");
        }

        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 21

              
    protected void setUp() throws Exception {
        ParserConfig.global = new ParserConfig();
        if (!JSON.DEFAULT_TYPE_KEY.equals("mySpace")) {
            JSON.setDefaultTypeKey("mySpace");
        }

        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
    }

            

Reported by PMD.

Potential violation of Law of Demeter (static property access)
Design

Line: 25

                          JSON.setDefaultTypeKey("mySpace");
        }

        com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
    }

    protected void tearDown() throws Exception {
        JSON.setDefaultTypeKey(original);
        ParserConfig.global = originalConfig;

            

Reported by PMD.

JUnit 4 tests that clean up tests should use the @After annotation, JUnit5 tests should use @AfterEach or @AfterAll
Design

Line: 28

                      com.alibaba.fastjson.parser.ParserConfig.global.addAccept("com.alibaba.json.bvt.bug.Issue585.");
    }

    protected void tearDown() throws Exception {
        JSON.setDefaultTypeKey(original);
        ParserConfig.global = originalConfig;
    }

    public void test_for_issue() throws Exception {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ConcurrentHashMapTest6.java
15 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 19

              
public class ConcurrentHashMapTest6 extends TestCase {

    public void test_concurrentHashmap() throws Exception {
        OffsetSerializeWrapper wrapper = new OffsetSerializeWrapper();
        wrapper.offsetTable.put(new MessageQueue(), new WeakReference<A>(new A(true)));
        String text = JSON.toJSONString(wrapper);
        Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 26

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 26

                      Assert.assertEquals("{\"offsetTable\":{{\"items\":[]}:{\"value\":true}}}", text);

        OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 28

                      OffsetSerializeWrapper wrapper2 = JSON.parseObject(text, OffsetSerializeWrapper.class);
        Assert.assertEquals(1, wrapper2.getOffsetTable().size());

        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 30

              
        Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {


            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 31

                      Iterator<Map.Entry<MessageQueue, WeakReference<A>>> iter = wrapper2.getOffsetTable().entrySet().iterator();
        Map.Entry<MessageQueue, WeakReference<A>> entry = iter.next();
        Assert.assertEquals(0, entry.getKey().getItems().size());
        Assert.assertEquals(true, entry.getValue().get().isValue());
    }

    public static class OffsetSerializeWrapper {

        private ConcurrentHashMap<MessageQueue, WeakReference<A>> offsetTable = new ConcurrentHashMap<MessageQueue, WeakReference<A>>();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/FastJsonJsonViewTest.java
15 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

              
public class FastJsonJsonViewTest extends TestCase {

    @SuppressWarnings("deprecation")
    public void test_0() throws Exception {
        FastJsonJsonView view = new FastJsonJsonView();

        Assert.assertEquals(Charset.forName("UTF-8"), view.getCharset());
        view.setCharset(Charset.forName("GBK"));

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 34

                      view.setDateFormat("yyyyMMdd");
		
        Assert.assertNotNull(view.getFeatures());
        Assert.assertEquals(1, view.getFeatures().length);

        view.setSerializerFeature(SerializerFeature.BrowserCompatible);
        Assert.assertEquals(1, view.getFeatures().length);
        Assert.assertEquals(SerializerFeature.BrowserCompatible, view.getFeatures()[0]);


            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 37

                      Assert.assertEquals(1, view.getFeatures().length);

        view.setSerializerFeature(SerializerFeature.BrowserCompatible);
        Assert.assertEquals(1, view.getFeatures().length);
        Assert.assertEquals(SerializerFeature.BrowserCompatible, view.getFeatures()[0]);

        view.setFeatures(SerializerFeature.DisableCheckSpecialChar, SerializerFeature.SortField);
        Assert.assertEquals(2, view.getFeatures().length);
        Assert.assertEquals(SerializerFeature.DisableCheckSpecialChar, view.getFeatures()[0]);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 41

                      Assert.assertEquals(SerializerFeature.BrowserCompatible, view.getFeatures()[0]);

        view.setFeatures(SerializerFeature.DisableCheckSpecialChar, SerializerFeature.SortField);
        Assert.assertEquals(2, view.getFeatures().length);
        Assert.assertEquals(SerializerFeature.DisableCheckSpecialChar, view.getFeatures()[0]);
        Assert.assertEquals(SerializerFeature.SortField, view.getFeatures()[1]);
        
        view.setFilters(serializeFilter);
		Assert.assertEquals(1, view.getFilters().length);

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 46

                      Assert.assertEquals(SerializerFeature.SortField, view.getFeatures()[1]);
        
        view.setFilters(serializeFilter);
		Assert.assertEquals(1, view.getFilters().length);
		Assert.assertEquals(serializeFilter, view.getFilters()[0]);
		
        Map<String, Object> model = new HashMap<String, Object>();
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();

            

Reported by PMD.

The String literal 'abc' appears 6 times in this file; the first occurrence is on line 64
Error

Line: 64

                      view.render(model, request, response);
        
        view.setCharset(Charset.forName("GBK"));
        view.render(Collections.singletonMap("abc", "cde"), request, response);
        
        view.setDisableCaching(false);
        view.setUpdateContentLength(false);
        view.render(model, request, response);
        

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 75

              
    }
 
    public void test_1() throws Exception {
    	
        FastJsonJsonView view = new FastJsonJsonView();
        
        Assert.assertNotNull(view.getFastJsonConfig());
        view.setFastJsonConfig(new FastJsonConfig());

            

Reported by PMD.

Probable detached JUnit test case.
Error

Line: 75

              
    }
 
    public void test_1() throws Exception {
    	
        FastJsonJsonView view = new FastJsonJsonView();
        
        Assert.assertNotNull(view.getFastJsonConfig());
        view.setFastJsonConfig(new FastJsonConfig());

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 122

                      String contentAsString = response.getContentAsString();
        int contentLength = response.getContentLength();

        Assert.assertEquals(contentLength, contentAsString.getBytes(view.getFastJsonConfig().getCharset().name()).length);
    }

    @Test
    public  void test_jsonp_invalidParam() throws Exception {
        FastJsonJsonView view = new FastJsonJsonView();

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 122

                      String contentAsString = response.getContentAsString();
        int contentLength = response.getContentLength();

        Assert.assertEquals(contentLength, contentAsString.getBytes(view.getFastJsonConfig().getCharset().name()).length);
    }

    @Test
    public  void test_jsonp_invalidParam() throws Exception {
        FastJsonJsonView view = new FastJsonJsonView();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/GroovyTest.java
15 issues
System.out.println is used
Design

Line: 29

                      GroovyObject aa = (GroovyObject) JSON.parseObject(textA, AClass);
        Assert.assertEquals(a.getProperty("id"), aa.getProperty("id"));
        
        System.out.println(a);

        // B类,继承于A
        Class BClass = loader.parseClass("class B extends A {\n" + //
        		"    String name\n" + //
        		"}");

            

Reported by PMD.

System.out.println is used
Design

Line: 46

                      

        // 序列化失败
        System.out.println(JSON.toJSONString(b, true));
    }
}

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 12

              
public class GroovyTest extends TestCase {

    public void test_groovy() throws Exception {
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        GroovyClassLoader loader = new GroovyClassLoader(parent);

        // A类
        Class AClass = loader.parseClass("class A {\n" + //

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 13

              public class GroovyTest extends TestCase {

    public void test_groovy() throws Exception {
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        GroovyClassLoader loader = new GroovyClassLoader(parent);

        // A类
        Class AClass = loader.parseClass("class A {\n" + //
                                         "    int id\n" + //

            

Reported by PMD.

Ensure that resources like this GroovyClassLoader object are closed after use
Error

Line: 14

              
    public void test_groovy() throws Exception {
        ClassLoader parent = Thread.currentThread().getContextClassLoader();
        GroovyClassLoader loader = new GroovyClassLoader(parent);

        // A类
        Class AClass = loader.parseClass("class A {\n" + //
                                         "    int id\n" + //
                                         "}");

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 22

                                                       "}");

        // A实例
        GroovyObject a = (GroovyObject) AClass.newInstance();
        a.setProperty("id", 33);
        String textA = JSON.toJSONString(a);
        
        GroovyObject aa = (GroovyObject) JSON.parseObject(textA, AClass);
        Assert.assertEquals(a.getProperty("id"), aa.getProperty("id"));

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 23

              
        // A实例
        GroovyObject a = (GroovyObject) AClass.newInstance();
        a.setProperty("id", 33);
        String textA = JSON.toJSONString(a);
        
        GroovyObject aa = (GroovyObject) JSON.parseObject(textA, AClass);
        Assert.assertEquals(a.getProperty("id"), aa.getProperty("id"));
        

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 27

                      String textA = JSON.toJSONString(a);
        
        GroovyObject aa = (GroovyObject) JSON.parseObject(textA, AClass);
        Assert.assertEquals(a.getProperty("id"), aa.getProperty("id"));
        
        System.out.println(a);

        // B类,继承于A
        Class BClass = loader.parseClass("class B extends A {\n" + //

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 27

                      String textA = JSON.toJSONString(a);
        
        GroovyObject aa = (GroovyObject) JSON.parseObject(textA, AClass);
        Assert.assertEquals(a.getProperty("id"), aa.getProperty("id"));
        
        System.out.println(a);

        // B类,继承于A
        Class BClass = loader.parseClass("class B extends A {\n" + //

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 37

                      		"}");

        // B实例
        GroovyObject b = (GroovyObject) BClass.newInstance();
        b.setProperty("name", "jobs");
        String textB = JSON.toJSONString(b);
        GroovyObject bb = (GroovyObject) JSON.parseObject(textB, BClass);
        Assert.assertEquals(b.getProperty("id"), bb.getProperty("id"));
        Assert.assertEquals(b.getProperty("name"), bb.getProperty("name"));

            

Reported by PMD.