The following issues were found

src/test/java/com/alibaba/json/bvt/parser/fieldTypeResolver/FieldTypeResolverTest.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: 15

              
public class FieldTypeResolverTest extends TestCase {

    public void test_0() throws Exception {
        String text = "{\"item_0\":{},\"item_1\":{}}";
        
        FieldTypeResolver fieldResolver = new FieldTypeResolver() {

            public Type resolve(Object object, String fieldName) {

            

Reported by PMD.

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

Line: 30

                      };
        
        JSONObject jsonObject = JSON.parseObject(text, JSONObject.class, fieldResolver);
        Assert.assertTrue(jsonObject.get("item_0") instanceof Item);
    }

    public static class Item {
        
    }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'text' (lines '16'-'31').
Error

Line: 16

              public class FieldTypeResolverTest extends TestCase {

    public void test_0() throws Exception {
        String text = "{\"item_0\":{},\"item_1\":{}}";
        
        FieldTypeResolver fieldResolver = new FieldTypeResolver() {

            public Type resolve(Object object, String fieldName) {
                if (fieldName.startsWith("item_")) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'text' (lines '16'-'31').
Error

Line: 16

              public class FieldTypeResolverTest extends TestCase {

    public void test_0() throws Exception {
        String text = "{\"item_0\":{},\"item_1\":{}}";
        
        FieldTypeResolver fieldResolver = new FieldTypeResolver() {

            public Type resolve(Object object, String fieldName) {
                if (fieldName.startsWith("item_")) {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'fieldResolver' (lines '18'-'31').
Error

Line: 18

                  public void test_0() throws Exception {
        String text = "{\"item_0\":{},\"item_1\":{}}";
        
        FieldTypeResolver fieldResolver = new FieldTypeResolver() {

            public Type resolve(Object object, String fieldName) {
                if (fieldName.startsWith("item_")) {
                    return Item.class;
                }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'fieldResolver' (lines '18'-'31').
Error

Line: 18

                  public void test_0() throws Exception {
        String text = "{\"item_0\":{},\"item_1\":{}}";
        
        FieldTypeResolver fieldResolver = new FieldTypeResolver() {

            public Type resolve(Object object, String fieldName) {
                if (fieldName.startsWith("item_")) {
                    return Item.class;
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/PrettyFormatTest2.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: 12

              
public class PrettyFormatTest2 extends TestCase {

    public void test_0() throws Exception {
        Model model = new Model();
        model.id = 123;
        model.name = "wenshao";
        String text = JSON.toJSONString(model, SerializerFeature.PrettyFormat);
        assertEquals("{\n" +

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 17

                      model.id = 123;
        model.name = "wenshao";
        String text = JSON.toJSONString(model, SerializerFeature.PrettyFormat);
        assertEquals("{\n" +
                "\t\"id\":123,\n" +
                "\t\"name\":\"wenshao\"\n" +
                "}", text);
        
        Assert.assertEquals("[\n\t{},\n\t{}\n]", JSON.toJSONString(new Object[] { new Object(), new Object() }, SerializerFeature.PrettyFormat));

            

Reported by PMD.

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

Line: 26

                  }

    public  static class Model {
        public int id;
        public String name;
    }
}

            

Reported by PMD.

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

Line: 27

              
    public  static class Model {
        public int id;
        public String name;
    }
}

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSONObject'
Design

Line: 4

              package com.alibaba.json.bvt.serializer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;


            

Reported by PMD.

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

Line: 5

              
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
import org.junit.Assert;

public class PrettyFormatTest2 extends TestCase {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/filters/NameFilterTest_IntegerKey.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: 16

              
public class NameFilterTest_IntegerKey extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("1001")) {
                    return "ID";

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 20

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("1001")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 20

                      NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("1001")) {
                    return "ID";
                }

                return name;
            }

            

Reported by PMD.

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

Line: 31

              
        SerializeWriter out = new SerializeWriter();
        JSONSerializer serializer = new JSONSerializer(out);
        serializer.getNameFilters().add(filter);

        Map map = new HashMap();
        map.put(1001, 0);
        serializer.write(map);


            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '17'-'39').
Error

Line: 17

              public class NameFilterTest_IntegerKey extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("1001")) {
                    return "ID";
                }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'filter' (lines '17'-'39').
Error

Line: 17

              public class NameFilterTest_IntegerKey extends TestCase {

    public void test_namefilter() throws Exception {
        NameFilter filter = new NameFilter() {

            public String process(Object source, String name, Object value) {
                if (name.equals("1001")) {
                    return "ID";
                }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/taobao/TradeTest.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 junit.framework.TestCase;

public class TradeTest extends TestCase {
    public void test_cast() {
        String s
                = "{\"period\":{\"label\":\"最近30天\",\"value\":\"30d\"},\"data\":{\"gmv\":{\"min\":-2},\"id\":3712312925}}";
        Param param;
        param = JSON.parseObject(s, Param.class); // 从字符串直接转化,OK
        assertNotNull(param);

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 14

                              = "{\"period\":{\"label\":\"最近30天\",\"value\":\"30d\"},\"data\":{\"gmv\":{\"min\":-2},\"id\":3712312925}}";
        Param param;
        param = JSON.parseObject(s, Param.class); // 从字符串直接转化,OK
        assertNotNull(param);

        JSONObject jobj = JSON.parseObject(s);
        param = jobj.toJavaObject(Param.class);
    }


            

Reported by PMD.

The value assigned to variable 'param' is never used
Design

Line: 17

                      assertNotNull(param);

        JSONObject jobj = JSON.parseObject(s);
        param = jobj.toJavaObject(Param.class);
    }

    public static class Param extends BaseObject {

        private static final long serialVersionUID = 5180807854744861824L;

            

Reported by PMD.

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

Line: 17

                      assertNotNull(param);

        JSONObject jobj = JSON.parseObject(s);
        param = jobj.toJavaObject(Param.class);
    }

    public static class Param extends BaseObject {

        private static final long serialVersionUID = 5180807854744861824L;

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSONException'
Design

Line: 4

              package com.alibaba.json.bvt.taobao;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import junit.framework.TestCase;

public class TradeTest extends TestCase {
    public void test_cast() {

            

Reported by PMD.

Found 'DU'-anomaly for variable 'param' (lines '17'-'18').
Error

Line: 17

                      assertNotNull(param);

        JSONObject jobj = JSON.parseObject(s);
        param = jobj.toJavaObject(Param.class);
    }

    public static class Param extends BaseObject {

        private static final long serialVersionUID = 5180807854744861824L;

            

Reported by PMD.

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

	public void test_typeRef() throws Exception {
		TypeReference<Map<String, Entity>> typeRef = new TypeReference<Map<String, Entity>>() {
		};

		Map<String, Entity> map = JSON
				.parseObject(

            

Reported by PMD.

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

Line: 22

              						"{\"value\":{\"id\":\"abc\",\"a\":{\"id\":123}}}",
						typeRef);

		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(123, entity.getA().getId());
	}


            

Reported by PMD.

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

Line: 24

              
		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(123, entity.getA().getId());
	}

	public static class Entity {
		private String id;

            

Reported by PMD.

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

Line: 25

              		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(123, entity.getA().getId());
	}

	public static class Entity {
		private String id;


            

Reported by PMD.

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

Line: 25

              		Entity entity = map.get("value");
		Assert.assertNotNull(entity);
		Assert.assertEquals("abc", entity.getId());
		Assert.assertEquals(123, entity.getA().getId());
	}

	public static class Entity {
		private String id;


            

Reported by PMD.

The class 'Entity' is suspected to be a Data Class (WOC=0.000%, NOPA=0, NOAM=4, WMC=4)
Design

Line: 28

              		Assert.assertEquals(123, entity.getA().getId());
	}

	public static class Entity {
		private String id;

		private A a;

		public String getId() {

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/path/JSONPath_1.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: 12

              
public class JSONPath_1 extends TestCase {

    public void test_path_empty() throws Exception {
        Throwable error = null;
        try {
            JSONPath.compile("");
        } catch (JSONPathException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_path_null() throws Exception {
        Throwable error = null;
        try {
            JSONPath.compile(null);
        } catch (JSONPathException ex) {
            error = ex;

            

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

                      Assert.assertNotNull(error);
    }
    
    public void test_path_null_1() throws Exception {
        Throwable error = null;
        try {
            new JSONPath(null);
        } catch (JSONPathException ex) {
            error = ex;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '13'-'17').
Error

Line: 13

              public class JSONPath_1 extends TestCase {

    public void test_path_empty() throws Exception {
        Throwable error = null;
        try {
            JSONPath.compile("");
        } catch (JSONPathException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '23'-'27').
Error

Line: 23

                  }
    
    public void test_path_null() throws Exception {
        Throwable error = null;
        try {
            JSONPath.compile(null);
        } catch (JSONPathException ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '33'-'37').
Error

Line: 33

                  }
    
    public void test_path_null_1() throws Exception {
        Throwable error = null;
        try {
            new JSONPath(null);
        } catch (JSONPathException ex) {
            error = ex;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/serializer/ObjectWriteTest.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

               * Created by wenshao on 15/03/2017.
 */
public class ObjectWriteTest extends TestCase {
    public void test_objectWriteTest() throws Exception {
        ObjectSerializer serializer = SerializeConfig.getGlobalInstance().getObjectWriter(Model.class);

        JSONSerializer jsonSerializer = new JSONSerializer();
        serializer.write(jsonSerializer, null, "a", Model.class, 0);


            

Reported by PMD.

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

Line: 14

               */
public class ObjectWriteTest extends TestCase {
    public void test_objectWriteTest() throws Exception {
        ObjectSerializer serializer = SerializeConfig.getGlobalInstance().getObjectWriter(Model.class);

        JSONSerializer jsonSerializer = new JSONSerializer();
        serializer.write(jsonSerializer, null, "a", Model.class, 0);

        String text = jsonSerializer.out.toString();

            

Reported by PMD.

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

Line: 17

                      ObjectSerializer serializer = SerializeConfig.getGlobalInstance().getObjectWriter(Model.class);

        JSONSerializer jsonSerializer = new JSONSerializer();
        serializer.write(jsonSerializer, null, "a", Model.class, 0);

        String text = jsonSerializer.out.toString();
        assertEquals("null", text);
    }


            

Reported by PMD.

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

Line: 19

                      JSONSerializer jsonSerializer = new JSONSerializer();
        serializer.write(jsonSerializer, null, "a", Model.class, 0);

        String text = jsonSerializer.out.toString();
        assertEquals("null", text);
    }

    public static class Model {
        public int id;

            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 20

                      serializer.write(jsonSerializer, null, "a", Model.class, 0);

        String text = jsonSerializer.out.toString();
        assertEquals("null", text);
    }

    public static class Model {
        public int id;
    }

            

Reported by PMD.

Avoid unused imports such as 'com.alibaba.fastjson.JSON'
Design

Line: 3

              package com.alibaba.json.bvt.serializer;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.ObjectSerializer;
import com.alibaba.fastjson.serializer.SerializeConfig;
import junit.framework.TestCase;

/**

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/deny/DenyTest15.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: 10

               * Created by wenshao on 29/01/2017.
 */
public class DenyTest15 extends TestCase {
    public void test_deny() throws Exception {
        String text = "{\"value\":{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}}";
        Exception error = null;
        try {
            Model model = JSON.parseObject(text, Model.class);
        } catch (Exception ex) {

            

Reported by PMD.

Avoid unused local variables such as 'model'.
Design

Line: 14

                      String text = "{\"value\":{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}}";
        Exception error = null;
        try {
            Model model = JSON.parseObject(text, Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 15

                      Exception error = null;
        try {
            Model model = JSON.parseObject(text, Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 18

                      } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }

    public static class Model {
        public Throwable value;
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '12'-'16').
Error

Line: 12

              public class DenyTest15 extends TestCase {
    public void test_deny() throws Exception {
        String text = "{\"value\":{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}}";
        Exception error = null;
        try {
            Model model = JSON.parseObject(text, Model.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.

Found 'DU'-anomaly for variable 'model' (lines '14'-'19').
Error

Line: 14

                      String text = "{\"value\":{\"@type\":\"com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase\"}}";
        Exception error = null;
        try {
            Model model = JSON.parseObject(text, Model.class);
        } catch (Exception ex) {
            error = ex;
        }
        assertNotNull(error);
    }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/UUIDDeserializerTest.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: 18

              
public class UUIDDeserializerTest extends TestCase {

    public void test_url() throws Exception {
        UUID id = UUID.randomUUID();
        Assert.assertEquals(id, JSON.parseObject("'" + id.toString() + "'", UUID.class));

        Assert.assertEquals(null, JSON.parseObject("null", UUID.class));


            

Reported by PMD.

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

Line: 20

              
    public void test_url() throws Exception {
        UUID id = UUID.randomUUID();
        Assert.assertEquals(id, JSON.parseObject("'" + id.toString() + "'", UUID.class));

        Assert.assertEquals(null, JSON.parseObject("null", UUID.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));

            

Reported by PMD.

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

Line: 25

                      Assert.assertEquals(null, JSON.parseObject("null", UUID.class));

        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());

    }

    public void test_url_error() throws Exception {

            

Reported by PMD.

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

Line: 26

              
        DefaultJSONParser parser = new DefaultJSONParser("null", ParserConfig.getGlobalInstance(), JSON.DEFAULT_PARSER_FEATURE);
        Assert.assertEquals(null, MiscCodec.instance.deserialze(parser, null, null));
        Assert.assertEquals(JSONToken.LITERAL_STRING, MiscCodec.instance.getFastMatchToken());

    }

    public void test_url_error() throws Exception {
        JSONException ex = null;

            

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

              
    }

    public void test_url_error() throws Exception {
        JSONException ex = null;
        try {
            JSON.parseObject("'123'", UUID.class);
        } catch (JSONException e) {
            ex = e;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ex' (lines '31'-'35').
Error

Line: 31

                  }

    public void test_url_error() throws Exception {
        JSONException ex = null;
        try {
            JSON.parseObject("'123'", UUID.class);
        } catch (JSONException e) {
            ex = e;
        }

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/MyMapFieldTest.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 MyMapFieldTest extends TestCase {

    public void test_null() throws Exception {
        Entity value = JSON.parseObject("{value:null}", Entity.class);
        Assert.assertNull(value.getValue());
    }

    public void test_empty() throws Exception {

            

Reported by PMD.

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

Line: 15

              
    public void test_null() throws Exception {
        Entity value = JSON.parseObject("{value:null}", Entity.class);
        Assert.assertNull(value.getValue());
    }

    public void test_empty() throws Exception {
        Exception error = null;
        try {

            

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

                      Assert.assertNull(value.getValue());
    }

    public void test_empty() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{value:{}}", Entity.class);
        } catch (Exception ex) {
            error = ex;

            

Reported by PMD.

Avoid catching generic exceptions such as NullPointerException, RuntimeException, Exception in try-catch block
Design

Line: 22

                      Exception error = null;
        try {
            JSON.parseObject("{value:{}}", Entity.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }


            

Reported by PMD.

Classes implementing Serializable should set a serialVersionUID
Error

Line: 41

                      }
    }

    public class MyMap<K, V> extends HashMap<K, V> {

    }
}

            

Reported by PMD.

Found 'DD'-anomaly for variable 'error' (lines '19'-'23').
Error

Line: 19

                  }

    public void test_empty() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{value:{}}", Entity.class);
        } catch (Exception ex) {
            error = ex;
        }

            

Reported by PMD.