The following issues were found
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest6.java
6 issues
Line: 13
* Created by wenshao on 14/08/2017.
*/
public class WriteClassNameTest6 extends TestCase {
public void test_for_writeClassName() throws Exception {
String json = "{\"@type\":\"java.util.HashMap\",\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest6$Model\",\"id\":1001}";
Model model = (Model) JSON.parse(json);
assertNotNull(model);
}
Reported by PMD.
Line: 17
String json = "{\"@type\":\"java.util.HashMap\",\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest6$Model\",\"id\":1001}";
Model model = (Model) JSON.parse(json);
assertNotNull(model);
}
public void test_for_writeClassName_1() throws Exception {
String json = "{\"@type\":\"java.util.HashMap\",\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest6$Model\",\"id\":1001}";
Reported by PMD.
Line: 20
assertNotNull(model);
}
public void test_for_writeClassName_1() throws Exception {
String json = "{\"@type\":\"java.util.HashMap\",\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest6$Model\",\"id\":1001}";
Model model = JSON.parseObject(json, Model.class);
assertNotNull(model);
}
Reported by PMD.
Line: 24
String json = "{\"@type\":\"java.util.HashMap\",\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest6$Model\",\"id\":1001}";
Model model = JSON.parseObject(json, Model.class);
assertNotNull(model);
}
@JSONType
public static class Model {
public int id;
Reported by PMD.
Line: 4
package com.alibaba.json.bvt.writeClassName;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
Reported by PMD.
Line: 6
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.annotation.JSONType;
import com.alibaba.fastjson.serializer.SerializerFeature;
import junit.framework.TestCase;
/**
* Created by wenshao on 14/08/2017.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest.java
6 issues
Line: 19
A a = new A();
a.setB(new B());
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest$A\",\"b\":{}}", text);
A a1 = (A) JSON.parse(text);
Assert.assertNotNull(a1.getB());
Reported by PMD.
Line: 11
public class WriteClassNameTest extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance().addAccept(this.getClass().getName() + ".");
}
public void test_list() throws Exception {
A a = new A();
Reported by PMD.
Line: 12
public class WriteClassNameTest extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance().addAccept(this.getClass().getName() + ".");
}
public void test_list() throws Exception {
A a = new A();
a.setB(new B());
Reported by PMD.
Line: 12
public class WriteClassNameTest extends TestCase {
protected void setUp() throws Exception {
com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance().addAccept(this.getClass().getName() + ".");
}
public void test_list() throws Exception {
A a = new A();
a.setB(new B());
Reported by PMD.
Line: 15
com.alibaba.fastjson.parser.ParserConfig.getGlobalInstance().addAccept(this.getClass().getName() + ".");
}
public void test_list() throws Exception {
A a = new A();
a.setB(new B());
String text = JSON.toJSONString(a, SerializerFeature.WriteClassName);
System.out.println(text);
Assert.assertEquals("{\"@type\":\"com.alibaba.json.bvt.writeClassName.WriteClassNameTest$A\",\"b\":{}}", text);
Reported by PMD.
Line: 24
A a1 = (A) JSON.parse(text);
Assert.assertNotNull(a1.getB());
}
private static class A {
private B b;
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/basic/LongBenchmark.java
6 issues
Line: 46
JSON.parseObject(json, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf2() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 10; ++i) {
Reported by PMD.
Line: 55
JSON.parseObject(json2, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf3() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000 * 10; ++i) {
Reported by PMD.
Line: 64
JSON.parseObject(json3, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public long v1;
public long v2;
Reported by PMD.
Line: 10
/**
* Created by wenshao on 04/08/2017.
*/
public class LongBenchmark {
static String json = "{\"v1\":-1883391953414482124,\"v2\":-3019416596934963650,\"v3\":6497525620823745793,\"v4\":2136224289077142499,\"v5\":-2090575024006307745}";
static String json2 = "{\"v1\":\"-1883391953414482124\",\"v2\":\"-3019416596934963650\",\"v3\":\"6497525620823745793\",\"v4\":\"2136224289077142499\",\"v5\":\"-2090575024006307745\"}";
static String json3 = "{\n" +
"\t\"v1\":-1883391953414482124,\n" +
"\t\"v2\":-3019416596934963650,\n" +
Reported by PMD.
Line: 21
"\t\"v5\":-2090575024006307745\n" +
"}";
public static void main(String[] args) throws Exception {
// Model model = new Model();
// model.v1 = new Random().nextLong();
// model.v2 = new Random().nextLong();
// model.v3 = new Random().nextLong();
// model.v4 = new Random().nextLong();
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import java.util.Random;
/**
* Created by wenshao on 04/08/2017.
*/
public class LongBenchmark {
Reported by PMD.
src/test/java/com/alibaba/json/test/a/JTest.java
6 issues
Line: 26
Group clz = new Group();
clz.setUulist(list);
String json = JSON.toJSONString(clz);
System.out.println(json);
Group clz1 = JSON.parseObject(json, Group.class);
System.out.println(clz1.getUulist().get(1)[1].getName());
}
}
Reported by PMD.
Line: 28
String json = JSON.toJSONString(clz);
System.out.println(json);
Group clz1 = JSON.parseObject(json, Group.class);
System.out.println(clz1.getUulist().get(1)[1].getName());
}
}
Reported by PMD.
Line: 10
import com.alibaba.fastjson.JSON;
public class JTest {
/**
* @param args
*/
public static void main(String[] args) {
Reported by PMD.
Line: 28
String json = JSON.toJSONString(clz);
System.out.println(json);
Group clz1 = JSON.parseObject(json, Group.class);
System.out.println(clz1.getUulist().get(1)[1].getName());
}
}
Reported by PMD.
Line: 28
String json = JSON.toJSONString(clz);
System.out.println(json);
Group clz1 = JSON.parseObject(json, Group.class);
System.out.println(clz1.getUulist().get(1)[1].getName());
}
}
Reported by PMD.
Line: 28
String json = JSON.toJSONString(clz);
System.out.println(json);
Group clz1 = JSON.parseObject(json, Group.class);
System.out.println(clz1.getUulist().get(1)[1].getName());
}
}
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/basic/FloatBenchmark_obj.java
6 issues
Line: 34
JSON.parseObject(json, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf2() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000; ++i) {
Reported by PMD.
Line: 43
JSON.parseObject(json2, Model.class);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public Float v1;
public Float v2;
Reported by PMD.
Line: 8
/**
* Created by wenshao on 04/08/2017.
*/
public class FloatBenchmark_obj {
static String json = "{\"v1\":0.012671709,\"v2\":0.6042485,\"v3\":0.13231707,\"v4\":0.80090785,\"v5\":0.6192943}";
static String json2 = "{\"v1\":\"0.012671709\",\"v2\":\"0.6042485\",\"v3\":\"0.13231707\",\"v4\":\"0.80090785\",\"v5\":\"0.6192943\"}";
public static void main(String[] args) throws Exception {
Model model = new Model();
Reported by PMD.
Line: 12
static String json = "{\"v1\":0.012671709,\"v2\":0.6042485,\"v3\":0.13231707,\"v4\":0.80090785,\"v5\":0.6192943}";
static String json2 = "{\"v1\":\"0.012671709\",\"v2\":\"0.6042485\",\"v3\":\"0.13231707\",\"v4\":\"0.80090785\",\"v5\":\"0.6192943\"}";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
Reported by PMD.
Line: 13
static String json2 = "{\"v1\":\"0.012671709\",\"v2\":\"0.6042485\",\"v3\":\"0.13231707\",\"v4\":\"0.80090785\",\"v5\":\"0.6192943\"}";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
Line: 13
static String json2 = "{\"v1\":\"0.012671709\",\"v2\":\"0.6042485\",\"v3\":\"0.13231707\",\"v4\":\"0.80090785\",\"v5\":\"0.6192943\"}";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
src/test/java/com/alibaba/json/test/benchmark/basic/FloatBenchmark_arrayMapping_obj.java
6 issues
Line: 35
JSON.parseObject(json, Model.class, Feature.SupportArrayToBean);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static void perf2() {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000; ++i) {
Reported by PMD.
Line: 44
JSON.parseObject(json2, Model.class, Feature.SupportArrayToBean);
}
long millis = System.currentTimeMillis() - start;
System.out.println("millis : " + millis);
}
public static class Model {
public Float v1;
public Float v2;
Reported by PMD.
Line: 9
/**
* Created by wenshao on 04/08/2017.
*/
public class FloatBenchmark_arrayMapping_obj {
static String json = "[0.012671709,0.6042485,0.13231707,0.80090785,0.6192943]";
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
Reported by PMD.
Line: 13
static String json = "[0.012671709,0.6042485,0.13231707,0.80090785,0.6192943]";
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
Reported by PMD.
Line: 14
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
Line: 14
static String json2 = "[\"0.012671709\",\"0.6042485\",\"0.13231707\",\"0.80090785\",\"0.6192943\"]";
public static void main(String[] args) throws Exception {
Model model = new Model();
// model.v1 = new Random().nextFloat();
// model.v2 = new Random().nextFloat();
// model.v3 = new Random().nextFloat();
// model.v4 = new Random().nextFloat();
// model.v5 = new Random().nextFloat();
Reported by PMD.
src/test/java/com/alibaba/json/bvt/builder/BuilderTest2.java
6 issues
Line: 13
public class BuilderTest2 extends TestCase {
public void test_create() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
Reported by PMD.
Line: 16
public void test_create() throws Exception {
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
Reported by PMD.
Line: 17
VO vo = JSON.parseObject("{\"id\":12304,\"name\":\"ljw\"}", VO.class);
Assert.assertEquals(12304, vo.getId());
Assert.assertEquals("ljw", vo.getName());
}
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
Reported by PMD.
Line: 21
}
@JSONType(builder=VOBuilder.class)
public static class VO {
private int id;
private String name;
public void setId(int id) {
this.id = id;
Reported by PMD.
Line: 45
@JSONPOJOBuilder(buildMethod="xxx")
public static class VOBuilder {
private VO vo = new VO();
public VO xxx() {
return vo;
}
Reported by PMD.
Line: 45
@JSONPOJOBuilder(buildMethod="xxx")
public static class VOBuilder {
private VO vo = new VO();
public VO xxx() {
return vo;
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/asm/FieldWriter.java
6 issues
Line: 39
*/
public final class FieldWriter {
FieldWriter next;
/**
* Access flags of this field.
*/
private final int access;
Reported by PMD.
Line: 44
/**
* Access flags of this field.
*/
private final int access;
/**
* The index of the constant pool item that contains the name of this method.
*/
private final int name;
Reported by PMD.
Line: 49
/**
* 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 field.
*/
private final int desc;
Reported by PMD.
Line: 54
/**
* The index of the constant pool item that contains the descriptor of this field.
*/
private final int desc;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
Reported by PMD.
Line: 99
*/
void put(final ByteVector out) {
final int mask = 393216; // Opcodes.ACC_DEPRECATED | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE | ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / (ClassWriter.ACC_SYNTHETIC_ATTRIBUTE / Opcodes.ACC_SYNTHETIC));
out.putShort(access & ~mask).putShort(name).putShort(desc);
int attributeCount = 0;
out.putShort(attributeCount);
}
}
Reported by PMD.
Line: 99
*/
void put(final ByteVector out) {
final int mask = 393216; // Opcodes.ACC_DEPRECATED | ClassWriter.ACC_SYNTHETIC_ATTRIBUTE | ((access & ClassWriter.ACC_SYNTHETIC_ATTRIBUTE) / (ClassWriter.ACC_SYNTHETIC_ATTRIBUTE / Opcodes.ACC_SYNTHETIC));
out.putShort(access & ~mask).putShort(name).putShort(desc);
int attributeCount = 0;
out.putShort(attributeCount);
}
}
Reported by PMD.
src/main/java/com/alibaba/fastjson/support/spring/MappingFastJsonValue.java
6 issues
Line: 29
* @see JSONPObject
*/
@Deprecated
public class MappingFastJsonValue implements JSONSerializable {
private static final String SECURITY_PREFIX = "/**/";
private static final int BrowserSecureMask = SerializerFeature.BrowserSecure.mask;
private Object value;
private String jsonpFunction;
Reported by PMD.
Line: 82
}
if ((features & BrowserSecureMask) != 0 || (writer.isEnabled(BrowserSecureMask))) {
writer.write(SECURITY_PREFIX);
}
writer.write(jsonpFunction);
writer.write('(');
Reported by PMD.
Line: 86
writer.write(SECURITY_PREFIX);
}
writer.write(jsonpFunction);
writer.write('(');
serializer.write(value);
writer.write(')');
}
}
Reported by PMD.
Line: 87
}
writer.write(jsonpFunction);
writer.write('(');
serializer.write(value);
writer.write(')');
}
}
Reported by PMD.
Line: 89
writer.write(jsonpFunction);
writer.write('(');
serializer.write(value);
writer.write(')');
}
}
Reported by PMD.
Line: 74
}
public void write(JSONSerializer serializer, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter writer = serializer.out;
if(jsonpFunction == null){
serializer.write(value);
return;
}
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues3796/bean/ObjectF1.java
6 issues
Line: 8
import java.util.List;
public class ObjectF1 {
long a = -1;
int b = 0;
long c = 0;
Reported by PMD.
Line: 8
import java.util.List;
public class ObjectF1 {
long a = -1;
int b = 0;
long c = 0;
Reported by PMD.
Line: 11
public class ObjectF1 {
long a = -1;
int b = 0;
long c = 0;
int d = 0;
Reported by PMD.
Line: 13
long a = -1;
int b = 0;
long c = 0;
int d = 0;
int e = 0;
Reported by PMD.
Line: 15
long c = 0;
int d = 0;
int e = 0;
@JSONField(serialize = false)
Reported by PMD.
Line: 17
int d = 0;
int e = 0;
@JSONField(serialize = false)
String f = "";
Reported by PMD.