The following issues were found

src/main/java/com/alibaba/fastjson/serializer/AnnotationSerializer.java
27 issues
The class 'AnnotationSerializer' has a Standard Cyclomatic Complexity of 16 (Highest = 15).
Design

Line: 17

              /**
 * Created by wenshao on 10/05/2017.
 */
public class AnnotationSerializer implements ObjectSerializer {
    private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;


            

Reported by PMD.

The class 'AnnotationSerializer' has a Modified Cyclomatic Complexity of 16 (Highest = 15).
Design

Line: 17

              /**
 * Created by wenshao on 10/05/2017.
 */
public class AnnotationSerializer implements ObjectSerializer {
    private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;


            

Reported by PMD.

Avoid using redundant field initializer for 'sun_AnnotationType'
Performance

Line: 18

               * Created by wenshao on 10/05/2017.
 */
public class AnnotationSerializer implements ObjectSerializer {
    private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;

    public static AnnotationSerializer instance = new AnnotationSerializer();

            

Reported by PMD.

Avoid using redundant field initializer for 'sun_AnnotationType_error'
Performance

Line: 19

               */
public class AnnotationSerializer implements ObjectSerializer {
    private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;

    public static AnnotationSerializer instance = new AnnotationSerializer();


            

Reported by PMD.

Avoid using redundant field initializer for 'sun_AnnotationType_getInstance'
Performance

Line: 20

              public class AnnotationSerializer implements ObjectSerializer {
    private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;

    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {

            

Reported by PMD.

Avoid using redundant field initializer for 'sun_AnnotationType_members'
Performance

Line: 21

                  private static volatile Class sun_AnnotationType = null;
    private static volatile boolean sun_AnnotationType_error = false;
    private static volatile Method sun_AnnotationType_getInstance = null;
    private static volatile Method sun_AnnotationType_members = null;

    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        Class objClass = object.getClass();

            

Reported by PMD.

The method 'write' has a Modified Cyclomatic Complexity of 15.
Design

Line: 25

              
    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        Class objClass = object.getClass();
        Class[] interfaces = objClass.getInterfaces();
        if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
            Class annotationClass = interfaces[0];


            

Reported by PMD.

The method 'write' has a Standard Cyclomatic Complexity of 15.
Design

Line: 25

              
    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        Class objClass = object.getClass();
        Class[] interfaces = objClass.getInterfaces();
        if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
            Class annotationClass = interfaces[0];


            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int)' has a cyclomatic complexity of 27.
Design

Line: 25

              
    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        Class objClass = object.getClass();
        Class[] interfaces = objClass.getInterfaces();
        if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
            Class annotationClass = interfaces[0];


            

Reported by PMD.

The method 'write(JSONSerializer, Object, Object, Type, int)' has an NPath complexity of 6146, current threshold is 200
Design

Line: 25

              
    public static AnnotationSerializer instance = new AnnotationSerializer();

    public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
        Class objClass = object.getClass();
        Class[] interfaces = objClass.getInterfaces();
        if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
            Class annotationClass = interfaces[0];


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONScannerTest_singQuoteString.java
27 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: 14

              
public class JSONScannerTest_singQuoteString extends TestCase {

    public void test_string() throws Exception {
        {
            JSONScanner lexer = new JSONScanner("\'中国\'");
            lexer.config(Feature.AllowSingleQuotes, true);
            lexer.nextToken();
            Assert.assertEquals("中国", lexer.stringVal());

            

Reported by PMD.

StringBuffer constructor is initialized with size 16, but has at least 28 characters appended.
Performance

Line: 34

                          Assert.assertEquals("中国\tV5", lexer.stringVal());
        }

        StringBuilder buf = new StringBuilder();

        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 36

              
        StringBuilder buf = new StringBuilder();

        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 36

              
        StringBuilder buf = new StringBuilder();

        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();

            

Reported by PMD.

Avoid concatenating nonliterals in a StringBuffer/StringBuilder constructor or append().
Performance

Line: 37

                      StringBuilder buf = new StringBuilder();

        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();


            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 37

                      StringBuilder buf = new StringBuilder();

        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();


            

Reported by PMD.

StringBuffer (or StringBuilder).append is called 2 consecutive times with literals. Use a single append with a single combined String.
Performance

Line: 38

              
        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);

            

Reported by PMD.

StringBuffer (or StringBuilder).append is called consecutively without reusing the target variable.
Performance

Line: 38

              
        buf.append('\'');
        buf.append("\\\\\\/\\b\\f\\n\\r\t\\u" + Integer.toHexString('中'));
        buf.append('\'');
        buf.append('\u2001');

        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);

            

Reported by PMD.

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

Line: 43

              
        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());


            

Reported by PMD.

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

Line: 43

              
        String text = buf.toString();

        JSONScanner lexer = new JSONScanner(text.toCharArray(), text.length() - 1);
        lexer.config(Feature.AllowSingleQuotes, true);
        lexer.nextToken();

        Assert.assertEquals(0, lexer.pos());


            

Reported by PMD.

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

    public void test_0() throws Exception {
        String text = "{value:'123',big:false}";
        Bean bean = JSON.parseObject(text, Bean.class);
        Assert.assertEquals("123", bean.getValue());
        Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());

            

Reported by PMD.

The String literal '{value:'123',big:false}' appears 10 times in this file; the first occurrence is on line 13
Error

Line: 13

              public class JSONObjectTest3 extends TestCase {

    public void test_0() throws Exception {
        String text = "{value:'123',big:false}";
        Bean bean = JSON.parseObject(text, Bean.class);
        Assert.assertEquals("123", bean.getValue());
        Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());


            

Reported by PMD.

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

Line: 15

                  public void test_0() throws Exception {
        String text = "{value:'123',big:false}";
        Bean bean = JSON.parseObject(text, Bean.class);
        Assert.assertEquals("123", bean.getValue());
        Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());

        bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());

            

Reported by PMD.

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

Line: 16

                      String text = "{value:'123',big:false}";
        Bean bean = JSON.parseObject(text, Bean.class);
        Assert.assertEquals("123", bean.getValue());
        Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());

        bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());


            

Reported by PMD.

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

Line: 17

                      Bean bean = JSON.parseObject(text, Bean.class);
        Assert.assertEquals("123", bean.getValue());
        Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());

        bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());

        bean.setID(567);

            

Reported by PMD.

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

Line: 19

                      Assert.assertEquals(false, bean.isBig());
        Assert.assertEquals(123, bean.getIntValue());

        bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());

        bean.setID(567);
        Assert.assertEquals(567, bean.getID());


            

Reported by PMD.

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

Line: 20

                      Assert.assertEquals(123, bean.getIntValue());

        bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());

        bean.setID(567);
        Assert.assertEquals(567, bean.getID());

    }

            

Reported by PMD.

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

Line: 22

                      bean.setBig(true);
        Assert.assertEquals(true, bean.isBig());

        bean.setID(567);
        Assert.assertEquals(567, bean.getID());

    }

    public void test_error_0() throws Exception {

            

Reported by PMD.

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

Line: 23

                      Assert.assertEquals(true, bean.isBig());

        bean.setID(567);
        Assert.assertEquals(567, bean.getID());

    }

    public void test_error_0() throws Exception {
        String text = "{value:'123',big:false}";

            

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

              
    }

    public void test_error_0() throws Exception {
        String text = "{value:'123',big:false}";
        Bean bean = JSON.parseObject(text, Bean.class);

        JSONException error = null;
        try {

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/asm/Type.java
27 issues
A class which only has private constructors should be final
Design

Line: 38

               * @author Eric Bruneton
 * @author Chris Nokleberg
 */
public class Type {
    /**
     * The <tt>void</tt> type.
     */
    public static final Type VOID_TYPE    = new Type(0, null, ('V' << 24) | (5 << 16) | (0 << 8) | 0, 1);


            

Reported by PMD.

The class 'Type' has a Standard Cyclomatic Complexity of 6 (Highest = 15).
Design

Line: 38

               * @author Eric Bruneton
 * @author Chris Nokleberg
 */
public class Type {
    /**
     * The <tt>void</tt> type.
     */
    public static final Type VOID_TYPE    = new Type(0, null, ('V' << 24) | (5 << 16) | (0 << 8) | 0, 1);


            

Reported by PMD.

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

Line: 91

                  /**
     * The sort of this Java type.
     */
    protected final int        sort;

    /**
     * A buffer containing the internal name of this Java type. This field is only used for reference types.
     */
    private final char[]     buf;

            

Reported by PMD.

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

Line: 96

                  /**
     * A buffer containing the internal name of this Java type. This field is only used for reference types.
     */
    private final char[]     buf;

    /**
     * The offset of the internal name of this Java type in {@link #buf buf} or, for primitive types, the size,
     * descriptor and getOpcode offsets for this type (byte 0 contains the size, byte 1 the descriptor, byte 2 the
     * offset for IALOAD or IASTORE, byte 3 the offset for all other instructions).

            

Reported by PMD.

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

Line: 103

                   * descriptor and getOpcode offsets for this type (byte 0 contains the size, byte 1 the descriptor, byte 2 the
     * offset for IALOAD or IASTORE, byte 3 the offset for all other instructions).
     */
    private final int        off;

    /**
     * The length of the internal name of this Java type.
     */
    private final int        len;

            

Reported by PMD.

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

Line: 108

                  /**
     * The length of the internal name of this Java type.
     */
    private final int        len;

    // ------------------------------------------------------------------------
    // Constructors
    // ------------------------------------------------------------------------


            

Reported by PMD.

The method 'getArgumentsAndReturnSizes(String)' has a cyclomatic complexity of 10.
Design

Line: 131

                      return getType(typeDescriptor.toCharArray(), 0);
    }

    public static int getArgumentsAndReturnSizes(final String desc) {
        int n = 1;
        int c = 1;
        while (true) {
            char car = desc.charAt(c++);
            if (car == ')') {

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 136

                      int c = 1;
        while (true) {
            char car = desc.charAt(c++);
            if (car == ')') {
                car = desc.charAt(c);
                return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
            } else if (car == 'L') {
                while (desc.charAt(c++) != ';') {
                }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 139

                          if (car == ')') {
                car = desc.charAt(c);
                return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
            } else if (car == 'L') {
                while (desc.charAt(c++) != ';') {
                }
                n += 1;
//            } else if (car == '[') {
//                while ((car = desc.charAt(c)) == '[') {

            

Reported by PMD.

Avoid assignments in operands
Error

Line: 140

                              car = desc.charAt(c);
                return n << 2 | (car == 'V' ? 0 : (car == 'D' || car == 'J' ? 2 : 1));
            } else if (car == 'L') {
                while (desc.charAt(c++) != ';') {
                }
                n += 1;
//            } else if (car == '[') {
//                while ((car = desc.charAt(c)) == '[') {
//                    ++c;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/JSONLexerTest_16.java
27 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              
import com.alibaba.fastjson.JSON;

public class JSONLexerTest_16 extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\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: 11

              
public class JSONLexerTest_16 extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
    }

    public void test_1() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));

            

Reported by PMD.

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

Line: 12

              public class JSONLexerTest_16 extends TestCase {

    public void test_0() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
    }

    public void test_1() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\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: 15

                      Assert.assertEquals(123, JSON.parseObject("{\"\\0\":123}").get("\0"));
    }

    public void test_1() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));

            

Reported by PMD.

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

Line: 16

                  }

    public void test_1() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
    }

            

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

                      Assert.assertEquals(123, JSON.parseObject("{\"\\1\":123}").get("\1"));
    }
    
    public void test_2() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));

            

Reported by PMD.

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

Line: 20

                  }
    
    public void test_2() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
    }

            

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

                      Assert.assertEquals(123, JSON.parseObject("{\"\\2\":123}").get("\2"));
    }
    
    public void test_3() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));

            

Reported by PMD.

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

Line: 24

                  }
    
    public void test_3() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));
    }

            

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

                      Assert.assertEquals(123, JSON.parseObject("{\"\\3\":123}").get("\3"));
    }
    
    public void test_4() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\4\":123}").get("\4"));
    }
    
    public void test_5() throws Exception {
        Assert.assertEquals(123, JSON.parseObject("{\"\\5\":123}").get("\5"));

            

Reported by PMD.

src/main/java/com/alibaba/fastjson/asm/MethodWriter.java
27 issues
This class has too many methods, consider refactoring it.
Design

Line: 36

               * @author Eric Bruneton
 * @author Eugene Kuleshov
 */
public class MethodWriter implements MethodVisitor {

    /**
     * Next method writer (see {@link ClassWriter#firstMethod firstMethod}).
     */
    MethodWriter       next;

            

Reported by PMD.

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

Line: 41

                  /**
     * Next method writer (see {@link ClassWriter#firstMethod firstMethod}).
     */
    MethodWriter       next;

    /**
     * The class writer to which this method must be added.
     */
    final ClassWriter  cw;

            

Reported by PMD.

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

Line: 46

                  /**
     * The class writer to which this method must be added.
     */
    final ClassWriter  cw;

    /**
     * Access flags of this method.
     */
    private int        access;

            

Reported by PMD.

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

Line: 51

                  /**
     * Access flags of this method.
     */
    private int        access;

    /**
     * The index of the constant pool item that contains the name of this method.
     */
    private final int  name;

            

Reported by PMD.

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

Line: 51

                  /**
     * Access flags of this method.
     */
    private int        access;

    /**
     * The index of the constant pool item that contains the name of this method.
     */
    private final int  name;

            

Reported by PMD.

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

Line: 56

                  /**
     * The index of the constant pool item that contains the name of this method.
     */
    private final int  name;

    /**
     * The index of the constant pool item that contains the descriptor of this method.
     */
    private final int  desc;

            

Reported by PMD.

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

Line: 61

                  /**
     * The index of the constant pool item that contains the descriptor of this method.
     */
    private final int  desc;

    /**
     * Number of exceptions that can be thrown by this method.
     */
    int                exceptionCount;

            

Reported by PMD.

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

Line: 66

                  /**
     * Number of exceptions that can be thrown by this method.
     */
    int                exceptionCount;

    /**
     * The exceptions that can be thrown by this method. More precisely, this array contains the indexes of the constant
     * pool items that contain the internal names of these exception classes.
     */

            

Reported by PMD.

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

Line: 72

                   * The exceptions that can be thrown by this method. More precisely, this array contains the indexes of the constant
     * pool items that contain the internal names of these exception classes.
     */
    int[]              exceptions;

    /**
     * The bytecode of this method.
     */
    private ByteVector code                                    = new ByteVector();

            

Reported by PMD.

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

Line: 77

                  /**
     * The bytecode of this method.
     */
    private ByteVector code                                    = new ByteVector();

    /**
     * Maximum stack size of this method.
     */
    private int        maxStack;

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/support/spring/FastJsonHttpMessageConverterTest.java
27 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: 29

              
public class FastJsonHttpMessageConverterTest extends TestCase {

	@SuppressWarnings("deprecation")
	public void test_read() throws Exception {
		FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
		converter.setCharset(Charset.forName("UTF-8"));
		Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());


            

Reported by PMD.

The String literal 'UTF-8' appears 6 times in this file; the first occurrence is on line 32
Error

Line: 32

              	@SuppressWarnings("deprecation")
	public void test_read() throws Exception {
		FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
		converter.setCharset(Charset.forName("UTF-8"));
		Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());

		converter.setFeatures(SerializerFeature.BrowserCompatible);
		Assert.assertEquals(1, converter.getFeatures().length);
		Assert.assertEquals(SerializerFeature.BrowserCompatible,

            

Reported by PMD.

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

Line: 36

              		Assert.assertEquals(Charset.forName("UTF-8"), converter.getCharset());

		converter.setFeatures(SerializerFeature.BrowserCompatible);
		Assert.assertEquals(1, converter.getFeatures().length);
		Assert.assertEquals(SerializerFeature.BrowserCompatible,
				converter.getFeatures()[0]);

		Assert.assertNull(converter.getDateFormat());
		converter.setDateFormat("yyyyMMdd");

            

Reported by PMD.

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

Line: 44

              		converter.setDateFormat("yyyyMMdd");

		converter.setFilters(serializeFilter);
		Assert.assertEquals(1, converter.getFilters().length);
		Assert.assertEquals(serializeFilter, converter.getFilters()[0]);

		converter.addSerializeFilter(serializeFilter);
		Assert.assertEquals(2, converter.getFilters().length);
		converter.addSerializeFilter(null);

            

Reported by PMD.

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

Line: 48

              		Assert.assertEquals(serializeFilter, converter.getFilters()[0]);

		converter.addSerializeFilter(serializeFilter);
		Assert.assertEquals(2, converter.getFilters().length);
		converter.addSerializeFilter(null);

		converter.setSupportedMediaTypes(Arrays
				.asList(new MediaType[] { MediaType.APPLICATION_JSON_UTF8 }));
		Assert.assertEquals(1, converter.getSupportedMediaTypes().size());

            

Reported by PMD.

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

Line: 53

              
		converter.setSupportedMediaTypes(Arrays
				.asList(new MediaType[] { MediaType.APPLICATION_JSON_UTF8 }));
		Assert.assertEquals(1, converter.getSupportedMediaTypes().size());

		Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
				"supports", Class.class);
		method.setAccessible(true);
		method.invoke(converter, int.class);

            

Reported by PMD.

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

Line: 57

              
		Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
				"supports", Class.class);
		method.setAccessible(true);
		method.invoke(converter, int.class);

		HttpInputMessage input = new HttpInputMessage() {

			public HttpHeaders getHeaders() {

            

Reported by PMD.

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

Line: 58

              		Method method = FastJsonHttpMessageConverter.class.getDeclaredMethod(
				"supports", Class.class);
		method.setAccessible(true);
		method.invoke(converter, int.class);

		HttpInputMessage input = new HttpInputMessage() {

			public HttpHeaders getHeaders() {
				// TODO Auto-generated method stub

            

Reported by PMD.

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

Line: 74

              
		};
		VO vo = (VO) converter.read(VO.class, input);
		Assert.assertEquals(123, vo.getId());

		final ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
		HttpOutputMessage out = new HttpOutputMessage() {

			public HttpHeaders getHeaders() {

            

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

              		Assert.assertEquals("{\"id\":\"123\"}", new String(bytes, "UTF-8"));
	}

	public void test_1() throws Exception {

		FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();

		Assert.assertNotNull(converter.getFastJsonConfig());
		converter.setFastJsonConfig(new FastJsonConfig());

            

Reported by PMD.

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

Line: 15

              import java.util.TimeZone;

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

    public void test_for_issue() throws Exception {

            

Reported by PMD.

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

Line: 20

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String text = "{\"createTime\":1548166745}";

        Order o = JSON.parseObject(text, Order.class);
        assertEquals(1548166745000L, o.createTime.getTime());


            

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

                      JSON.defaultLocale = Locale.CHINA;
    }

    public void test_for_issue() throws Exception {
        String text = "{\"createTime\":1548166745}";

        Order o = JSON.parseObject(text, Order.class);
        assertEquals(1548166745000L, o.createTime.getTime());


            

Reported by PMD.

The String literal '{\'createTime\':1548166745}' appears 6 times in this file; the first occurrence is on line 21
Error

Line: 21

                  }

    public void test_for_issue() throws Exception {
        String text = "{\"createTime\":1548166745}";

        Order o = JSON.parseObject(text, Order.class);
        assertEquals(1548166745000L, o.createTime.getTime());

        String json = JSON.toJSONString(o);

            

Reported by PMD.

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

Line: 24

                      String text = "{\"createTime\":1548166745}";

        Order o = JSON.parseObject(text, Order.class);
        assertEquals(1548166745000L, o.createTime.getTime());

        String json = JSON.toJSONString(o);
        assertEquals("{\"createTime\":1548166745}", json);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 24

                      String text = "{\"createTime\":1548166745}";

        Order o = JSON.parseObject(text, Order.class);
        assertEquals(1548166745000L, o.createTime.getTime());

        String json = JSON.toJSONString(o);
        assertEquals("{\"createTime\":1548166745}", json);
    }


            

Reported by PMD.

JUnit assertions should include a message
Design

Line: 27

                      assertEquals(1548166745000L, o.createTime.getTime());

        String json = JSON.toJSONString(o);
        assertEquals("{\"createTime\":1548166745}", json);
    }

    public void test_for_issue2() throws Exception {
        String text = "{\"createTime\":1548166745}";


            

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

                      assertEquals("{\"createTime\":1548166745}", json);
    }

    public void test_for_issue2() throws Exception {
        String text = "{\"createTime\":1548166745}";

        Order2 o = JSON.parseObject(text, Order2.class);
        assertEquals(1548166745000L, o.createTime.getTimeInMillis());


            

Reported by PMD.

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

Line: 30

                      assertEquals("{\"createTime\":1548166745}", json);
    }

    public void test_for_issue2() throws Exception {
        String text = "{\"createTime\":1548166745}";

        Order2 o = JSON.parseObject(text, Order2.class);
        assertEquals(1548166745000L, o.createTime.getTimeInMillis());


            

Reported by PMD.

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

Line: 34

                      String text = "{\"createTime\":1548166745}";

        Order2 o = JSON.parseObject(text, Order2.class);
        assertEquals(1548166745000L, o.createTime.getTimeInMillis());

        String json = JSON.toJSONString(o);
        assertEquals("{\"createTime\":1548166745}", json);
    }


            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/bug/Bug_127_for_qiuyan81.java
27 issues
This class has too many methods, consider refactoring it.
Design

Line: 10

              
import junit.framework.TestCase;

public class Bug_127_for_qiuyan81 extends TestCase {

    public void test_parserUndefined() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined}";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.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: 12

              
public class Bug_127_for_qiuyan81 extends TestCase {

    public void test_parserUndefined() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined}";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    

            

Reported by PMD.

The String literal '{\'PayStatus\':0}' appears 7 times in this file; the first occurrence is on line 15
Error

Line: 15

                  public void test_parserUndefined() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined}";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    
    public void test_parserUndefined_space() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined }";
        Object json = JSON.parse(jsonString);

            

Reported by PMD.

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

Line: 15

                  public void test_parserUndefined() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined}";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    
    public void test_parserUndefined_space() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined }";
        Object json = JSON.parse(jsonString);

            

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.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    
    public void test_parserUndefined_space() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined }";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    

            

Reported by PMD.

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

Line: 21

                  public void test_parserUndefined_space() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined }";
        Object json = JSON.parse(jsonString);
        Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    
    public void test_parserUndefined_comma() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
        JSONObject json = (JSONObject) JSON.parse(jsonString);

            

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

                      Assert.assertEquals("{\"PayStatus\":0}", json.toString());
    }
    
    public void test_parserUndefined_comma() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
        JSONObject json = (JSONObject) JSON.parse(jsonString);
        Assert.assertEquals(1001, json.get("ext"));
        Assert.assertEquals(0, json.get("PayStatus"));
        Assert.assertEquals(3, json.size());

            

Reported by PMD.

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

Line: 27

                  public void test_parserUndefined_comma() {
        String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
        JSONObject json = (JSONObject) JSON.parse(jsonString);
        Assert.assertEquals(1001, json.get("ext"));
        Assert.assertEquals(0, json.get("PayStatus"));
        Assert.assertEquals(3, json.size());
    }
    
    public void test_parserUndefined_array() {

            

Reported by PMD.

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

Line: 28

                      String jsonString = "{PayStatus:0,RunEmpId:undefined,ext:1001}";
        JSONObject json = (JSONObject) JSON.parse(jsonString);
        Assert.assertEquals(1001, json.get("ext"));
        Assert.assertEquals(0, json.get("PayStatus"));
        Assert.assertEquals(3, json.size());
    }
    
    public void test_parserUndefined_array() {
        String jsonString = "[0,undefined]";

            

Reported by PMD.

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

Line: 29

                      JSONObject json = (JSONObject) JSON.parse(jsonString);
        Assert.assertEquals(1001, json.get("ext"));
        Assert.assertEquals(0, json.get("PayStatus"));
        Assert.assertEquals(3, json.size());
    }
    
    public void test_parserUndefined_array() {
        String jsonString = "[0,undefined]";
        Object json = JSON.parse(jsonString);

            

Reported by PMD.

src/test/java/com/alibaba/json/bvt/parser/deser/StackTraceElementDeserializerTest.java
27 issues
This class has too many methods, consider refactoring it.
Design

Line: 9

              import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;

public class StackTraceElementDeserializerTest extends TestCase {

    public void test_stack() throws Exception {
        Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(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: 11

              
public class StackTraceElementDeserializerTest extends TestCase {

    public void test_stack() throws Exception {
        Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",

            

Reported by PMD.

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

Line: 14

                  public void test_stack() throws Exception {
        Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
                                           StackTraceElement.class).getFileName());
        
        Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());

            

Reported by PMD.

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

Line: 15

                      Assert.assertNull(JSON.parseObject("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
                                           StackTraceElement.class).getFileName());
        
        Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
    }

            

Reported by PMD.

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

Line: 16

                      Assert.assertNull(JSON.parseArray("null", StackTraceElement.class));
        Assert.assertNull(JSON.parseArray("[null]", StackTraceElement.class).get(0));
        Assert.assertNull(JSON.parseObject("{\"value\":null}", VO.class).getValue());
        Assert.assertNull(JSON.parseObject("{\"className\":\"int\",\"methodName\":\"parseInt\"}",
                                           StackTraceElement.class).getFileName());
        
        Assert.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
    }


            

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.assertEquals(StackTraceElement.class, ((StackTraceElement) JSON.parse("{\"@type\":\"java.lang.StackTraceElement\",\"className\":\"int\",\"methodName\":\"parseInt\",\"nativeMethod\":null}")).getClass());
    }

    public void test_stack_error() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{}", StackTraceElement.class);
        } catch (JSONException 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_stack_error_1() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("[]", StackTraceElement.class);
        } catch (JSONException 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: 42

                      Assert.assertNotNull(error);
    }
    
    public void test_stack_error_2() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"className\":null,\"methodName\":null,\"fileName\":null,\"lineNumber\":null,\"@type\":\"xxx\"}", StackTraceElement.class);
        } catch (JSONException 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: 52

                      Assert.assertNotNull(error);
    }
    
    public void test_stack_error_3() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"@type\":int}", StackTraceElement.class);
        } catch (JSONException 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: 62

                      Assert.assertNotNull(error);
    }
    
    public void test_stack_error_4() throws Exception {
        Exception error = null;
        try {
            JSON.parseObject("{\"xxx\":33}", StackTraceElement.class);
        } catch (JSONException ex) {
            error = ex;

            

Reported by PMD.