The following issues were found

src/test/java/com/alibaba/json/bvt/jdk8/ZonedDateTimeTest2.java
6 issues
System.out.println is used
Design

Line: 18

                      vo.date = ZonedDateTime.now();
        
        String text = JSON.toJSONString(vo);
        System.out.println(text);
        
        VO vo1 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.date.getSecond(), vo1.date.getSecond());
    }

            

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 ZonedDateTimeTest2 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = new VO();
        vo.date = ZonedDateTime.now();
        
        String text = JSON.toJSONString(vo);
        System.out.println(text);

            

Reported by PMD.

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

Line: 22

                      
        VO vo1 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.date.getSecond(), vo1.date.getSecond());
    }

    public static class VO {
        @JSONField(format="yyyy-MM-dd HH:mm:ss")
        public ZonedDateTime date;

            

Reported by PMD.

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

Line: 22

                      
        VO vo1 = JSON.parseObject(text, VO.class);
        
        Assert.assertEquals(vo.date.getSecond(), vo1.date.getSecond());
    }

    public static class VO {
        @JSONField(format="yyyy-MM-dd HH:mm:ss")
        public ZonedDateTime date;

            

Reported by PMD.

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

Line: 27

              
    public static class VO {
        @JSONField(format="yyyy-MM-dd HH:mm:ss")
        public ZonedDateTime date;

    }
}

            

Reported by PMD.

Avoid unused imports such as 'java.time.temporal.TemporalField'
Design

Line: 9

              import org.junit.Assert;

import java.time.ZonedDateTime;
import java.time.temporal.TemporalField;

public class ZonedDateTimeTest2 extends TestCase {

    public void test_for_issue() throws Exception {
        VO vo = new VO();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1400/Issue1494.java
6 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: 11

              import junit.framework.TestCase;

public class Issue1494 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"id\":1001,\"name\":\"wenshao\"}";
        B b = JSON.parseObject(json, B.class);
        assertEquals("{\"id\":1001,\"name\":\"wenshao\"}", JSON.toJSONString(b));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_for_issue() throws Exception {
        String json = "{\"id\":1001,\"name\":\"wenshao\"}";
        B b = JSON.parseObject(json, B.class);
        assertEquals("{\"id\":1001,\"name\":\"wenshao\"}", JSON.toJSONString(b));
    }

    public static class A {
        private int id;


            

Reported by PMD.

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

Line: 18

                  }

    public static class A {
        private int id;

        public int getId() {
            return id;
        }
    }

            

Reported by PMD.

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

Line: 27

              
    @JSONType(parseFeatures = Feature.SupportNonPublicField)
    public static class B extends A {
        private String name;

        public String getName() {
            return name;
        }
    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.parser.ParserConfig'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;

public class Issue1494 extends TestCase {
    public void test_for_issue() throws Exception {

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.serializer.SerializeConfig'
Design

Line: 7

              import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;

public class Issue1494 extends TestCase {
    public void test_for_issue() throws Exception {
        String json = "{\"id\":1001,\"name\":\"wenshao\"}";

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1600/Issue1603_map_getter.java
6 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: 11

              import java.util.Map;

public class Issue1603_map_getter extends TestCase {
    public void test_emptyMap() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifiableMap() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 13

              public class Issue1603_map_getter extends TestCase {
    public void test_emptyMap() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifiableMap() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
        assertEquals(0, m.values.size());

            

Reported by PMD.

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

Line: 13

              public class Issue1603_map_getter extends TestCase {
    public void test_emptyMap() throws Exception {
        Model_1 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_1.class);
        assertEquals(0, m.values.size());
    }

    public void test_unmodifiableMap() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
        assertEquals(0, m.values.size());

            

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: 16

                      assertEquals(0, m.values.size());
    }

    public void test_unmodifiableMap() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

              
    public void test_unmodifiableMap() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {
        private final Map<String, Object> values = Collections.emptyMap();


            

Reported by PMD.

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

Line: 18

              
    public void test_unmodifiableMap() throws Exception {
        Model_2 m = JSON.parseObject("{\"values\":{\"a\":1001}}", Model_2.class);
        assertEquals(0, m.values.size());
    }

    public static class Model_1 {
        private final Map<String, Object> values = Collections.emptyMap();


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_2300/Issue2346.java
6 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: 11

              import lombok.Getter;

public class Issue2346 extends TestCase {
    public void test_for_issue() throws Exception {
        String jsonStr = "{\"age\":1,\"name\":\"aa\"}";
        TestEntity testEntity = JSON.parseObject(jsonStr, TestEntity.class);
        assertEquals(jsonStr, JSON.toJSONString(testEntity));
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                  public void test_for_issue() throws Exception {
        String jsonStr = "{\"age\":1,\"name\":\"aa\"}";
        TestEntity testEntity = JSON.parseObject(jsonStr, TestEntity.class);
        assertEquals(jsonStr, JSON.toJSONString(testEntity));
    }

    @Builder(builderClassName = "TestEntityBuilder")
    @Getter
    @JSONType(builder = TestEntity.TestEntityBuilder.class)

            

Reported by PMD.

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

Line: 40

              
        @JSONPOJOBuilder(withPrefix = "www")
        public static class TestEntity2Builder{
            private TestEntity2 testEntity2 = new TestEntity2();

            public TestEntity2 build(){
                return testEntity2;
            }


            

Reported by PMD.

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

Line: 40

              
        @JSONPOJOBuilder(withPrefix = "www")
        public static class TestEntity2Builder{
            private TestEntity2 testEntity2 = new TestEntity2();

            public TestEntity2 build(){
                return testEntity2;
            }


            

Reported by PMD.

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

Line: 66

                      private int age;

        public static class TestEntity3Builder{
            private TestEntity3 testEntity3 = new TestEntity3();

            public TestEntity3 build(){
                return testEntity3;
            }


            

Reported by PMD.

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

Line: 66

                      private int age;

        public static class TestEntity3Builder{
            private TestEntity3 testEntity3 = new TestEntity3();

            public TestEntity3 build(){
                return testEntity3;
            }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/joda/JodaTest_6_Duration.java
6 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: 9

              import org.joda.time.Period;

public class JodaTest_6_Duration extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();
       m.duration = new Duration(24L*60L*60L*1000L);

       String json = JSON.toJSONString(m);

            

Reported by PMD.

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

Line: 9

              import org.joda.time.Period;

public class JodaTest_6_Duration extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();
       m.duration = new Duration(24L*60L*60L*1000L);

       String json = JSON.toJSONString(m);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 16

              
       String json = JSON.toJSONString(m);

       assertEquals("{\"duration\":\"PT86400S\"}", json);

       Model m1 = JSON.parseObject(json, Model.class);
       assertEquals(m.duration, m1.duration);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                     assertEquals("{\"duration\":\"PT86400S\"}", json);

       Model m1 = JSON.parseObject(json, Model.class);
       assertEquals(m.duration, m1.duration);
    }

    public static class Model {
        public Duration duration;
    }

            

Reported by PMD.

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

Line: 23

                  }

    public static class Model {
        public Duration duration;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'org.joda.time.Period'
Design

Line: 6

              import com.alibaba.fastjson.JSON;
import junit.framework.TestCase;
import org.joda.time.Duration;
import org.joda.time.Period;

public class JodaTest_6_Duration extends TestCase {
    public void test_for_joda_0() throws Exception {

       Model m = new Model();

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/builder/BuilderTest_error_private.java
6 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 BuilderTest_error_private extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.

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

Line: 26

                  @JSONType(builder = VOBuilder.class)
    public static class VO {

        private int    id;
        private String name;

        public int getId() {
            return id;
        }

            

Reported by PMD.

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

Line: 27

                  public static class VO {

        private int    id;
        private String name;

        public int getId() {
            return id;
        }


            

Reported by PMD.

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

Line: 40

              
    private static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            throw new IllegalStateException();
        }


            

Reported by PMD.

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

Line: 40

              
    private static class VOBuilder {

        private VO vo = new VO();

        public VO build() {
            throw new IllegalStateException();
        }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '14'-'18').
Error

Line: 14

              public class BuilderTest_error_private extends TestCase {

    public void test_0() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
        } catch (JSONException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/kotlin/Zoujing.java
6 issues
System.out.println is used
Design

Line: 18

                      String json = "{\"benefitNoticeState\":1}";
        Object obj = JSON.parseObject(json, clazz);
        String result = JSON.toJSONString(obj);
        System.out.println(result);
        assertEquals("{\"benefitNoticeState\":1,\"outId\":\"\"}", result);
    }

    private static class ExtClassLoader extends ClassLoader {


            

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: 11

              import java.io.InputStream;

public class Zoujing extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazz = classLoader.loadClass("com.alidme.xrecharge.platform.common.data.NoticeData");

        String json = "{\"benefitNoticeState\":1}";
        Object obj = JSON.parseObject(json, clazz);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 19

                      Object obj = JSON.parseObject(json, clazz);
        String result = JSON.toJSONString(obj);
        System.out.println(result);
        assertEquals("{\"benefitNoticeState\":1,\"outId\":\"\"}", result);
    }

    private static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

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

Line: 29

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeData.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeData", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 38

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeDataKt.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeDataKt", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 47

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/zuojing/NoticeData_Companion.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("com.alidme.xrecharge.platform.common.data.NoticeData$Companion", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 17

              import junit.framework.TestCase;

public class DateTest_tz extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_codec() throws Exception {

            

Reported by PMD.

The String literal 'Asia/Shanghai' appears 4 times in this file; the first occurrence is on line 18
Error

Line: 18

              
public class DateTest_tz extends TestCase {
    protected void setUp() throws Exception {
        JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
        JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_codec() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":\"2016-04-29\"}"));

            

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: 22

                      JSON.defaultLocale = Locale.CHINA;
    }
    
    public void test_codec() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":\"2016-04-29\"}"));
        reader.setLocale(Locale.CHINA);
        reader.setTimzeZone(TimeZone.getTimeZone("Asia/Shanghai"));
        
        Model model = reader.readObject(Model.class);

            

Reported by PMD.

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

Line: 33

                      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
        Date date = format.parse("2016-04-29");
        Assert.assertEquals(date.getTime(), model.value.getTime());
        
        Assert.assertEquals(TimeZone.getTimeZone("Asia/Shanghai"), reader.getTimzeZone());
        Assert.assertEquals(Locale.CHINA, reader.getLocal());
        
        reader.close();

            

Reported by PMD.

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

Line: 33

                      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA);
        format.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
        Date date = format.parse("2016-04-29");
        Assert.assertEquals(date.getTime(), model.value.getTime());
        
        Assert.assertEquals(TimeZone.getTimeZone("Asia/Shanghai"), reader.getTimzeZone());
        Assert.assertEquals(Locale.CHINA, reader.getLocal());
        
        reader.close();

            

Reported by PMD.

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

Line: 42

                  }
    
    public static class Model {
        public Date value;
    }
}

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/issue_1400/Issue1498.java
6 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: 7

              import junit.framework.TestCase;

public class Issue1498 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"flag\":\"QUALITY_GRADUATE\"}", Model.class);
        assertNull(model.flag);
    }

    public void test_for_issue_match() throws Exception {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 9

              public class Issue1498 extends TestCase {
    public void test_for_issue() throws Exception {
        Model model = JSON.parseObject("{\"flag\":\"QUALITY_GRADUATE\"}", Model.class);
        assertNull(model.flag);
    }

    public void test_for_issue_match() throws Exception {
        Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
        assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);

            

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

                      assertNull(model.flag);
    }

    public void test_for_issue_match() throws Exception {
        Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
        assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);
    }

    public static class Model {

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

              
    public void test_for_issue_match() throws Exception {
        Model model = JSON.parseObject("{\"flag\":\"IS_NEED_CHECK_IDENTITY\"}", Model.class);
        assertSame(BuFlag.IS_NEED_CHECK_IDENTITY, model.flag);
    }

    public static class Model {
        public BuFlag flag;
    }

            

Reported by PMD.

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

Line: 18

                  }

    public static class Model {
        public BuFlag flag;
    }

    public enum BuFlag
    {
        IS_NEED_CHECK_IDENTITY(1L, "a"),  HAS_CHECK_IDENTITY(2L, "b");

            

Reported by PMD.

Perhaps 'desc' could be replaced by a local variable.
Design

Line: 26

                      IS_NEED_CHECK_IDENTITY(1L, "a"),  HAS_CHECK_IDENTITY(2L, "b");

        private long bit;
        private String desc;

        private BuFlag(long bit, String desc)
        {
            this.bit = bit;
            this.desc = desc;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/kotlin/Issue1543.java
6 issues
JUnit tests should include assert() or fail()
Design

Line: 14

              import java.util.Map;

public class Issue1543 extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazzUser = classLoader.loadClass("User1");

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 1);

            

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: 14

              import java.util.Map;

public class Issue1543 extends TestCase {
    public void test_user() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazzUser = classLoader.loadClass("User1");

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 1);

            

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: 25

                      JSON.parseObject(JSON.toJSONString(map), clazzUser);
    }

    public void test_cluster() throws Exception {
        ExtClassLoader classLoader = new ExtClassLoader();
        Class clazzCluster = classLoader.loadClass("Cluster");

        Object cluster = JSON.parseObject(JSON.toJSONString(Collections.singletonMap("cluster_enabled", 1)), clazzCluster);
        assertEquals("{\"cluster_enabled\":1}", JSON.toJSONString(cluster));

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 30

                      Class clazzCluster = classLoader.loadClass("Cluster");

        Object cluster = JSON.parseObject(JSON.toJSONString(Collections.singletonMap("cluster_enabled", 1)), clazzCluster);
        assertEquals("{\"cluster_enabled\":1}", JSON.toJSONString(cluster));
    }

    public static class ExtClassLoader extends ClassLoader {

        public ExtClassLoader() throws IOException {

            

Reported by PMD.

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

Line: 40

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1543/User1.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("User1", bytes, 0, bytes.length);
            }

            

Reported by PMD.

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

Line: 49

              
            {
                byte[] bytes;
                InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("kotlin/issue1543/Cluster.clazz");
                bytes = IOUtils.toByteArray(is);
                is.close();

                super.defineClass("Cluster", bytes, 0, bytes.length);
            }

            

Reported by PMD.