The following issues were found
src/main/java/com/alibaba/fastjson/asm/Label.java
4 issues
Line: 41
* @author Eric Bruneton
*/
public class Label {
int status;
/**
* The position of this label in the code, if known.
*/
int position;
Reported by PMD.
Line: 46
/**
* The position of this label in the code, if known.
*/
int position;
/**
* Number of forward references to this label, times two.
*/
private int referenceCount;
Reported by PMD.
Line: 51
/**
* Number of forward references to this label, times two.
*/
private int referenceCount;
/**
* Informations about forward references. Each forward reference is described by two consecutive integers in this
* array: the first one is the position of the first byte of the bytecode instruction that contains the forward
* reference, while the second is the position of the first byte of the forward reference itself. In fact the sign
Reported by PMD.
Line: 62
* belongs. This information is needed in MethodWriter#visitMaxs, after all forward references have been
* resolved. Hence the same array can be used for both purposes without problems.
*/
private int[] srcAndRefPositions;
/**
* The bit mask to extract the type of a forward reference to this label. The extracted type is
* either {@link #FORWARD_REFERENCE_TYPE_SHORT} or {@link #FORWARD_REFERENCE_TYPE_WIDE}.
*/
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TestForPascalStyle.java
4 issues
Line: 10
public class TestForPascalStyle extends TestCase {
public void test_for_pascal_style() throws Exception {
String text = "{\"ID\":12,\"Name\":\"Jobs\"}";
VO vo = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getId(), 12);
Assert.assertEquals(vo.getName(), "Jobs");
}
Reported by PMD.
Line: 13
public void test_for_pascal_style() throws Exception {
String text = "{\"ID\":12,\"Name\":\"Jobs\"}";
VO vo = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getId(), 12);
Assert.assertEquals(vo.getName(), "Jobs");
}
public static class VO {
Reported by PMD.
Line: 14
String text = "{\"ID\":12,\"Name\":\"Jobs\"}";
VO vo = JSON.parseObject(text, VO.class);
Assert.assertEquals(vo.getId(), 12);
Assert.assertEquals(vo.getName(), "Jobs");
}
public static class VO {
private int id;
Reported by PMD.
Line: 17
Assert.assertEquals(vo.getName(), "Jobs");
}
public static class VO {
private int id;
private String name;
public int getId() {
Reported by PMD.
src/test/java/com/alibaba/fastjson/deserializer/issues569/parser/DefaultFieldDeserializerBug569.java
4 issues
Line: 41
Object value;
if (fieldValueDeserilizer instanceof JavaBeanDeserializer) {
JavaBeanDeserializer javaBeanDeser = (JavaBeanDeserializer) fieldValueDeserilizer;
value = javaBeanDeser.deserialze(parser, fieldType, fieldInfo.name, fieldInfo.parserFeatures);
} else {
if (this.fieldInfo.format != null && fieldValueDeserilizer instanceof ContextObjectDeserializer) {
value = ((ContextObjectDeserializer) fieldValueDeserilizer) //
.deserialze(parser, fieldType,
fieldInfo.name,
Reported by PMD.
Line: 41
Object value;
if (fieldValueDeserilizer instanceof JavaBeanDeserializer) {
JavaBeanDeserializer javaBeanDeser = (JavaBeanDeserializer) fieldValueDeserilizer;
value = javaBeanDeser.deserialze(parser, fieldType, fieldInfo.name, fieldInfo.parserFeatures);
} else {
if (this.fieldInfo.format != null && fieldValueDeserilizer instanceof ContextObjectDeserializer) {
value = ((ContextObjectDeserializer) fieldValueDeserilizer) //
.deserialze(parser, fieldType,
fieldInfo.name,
Reported by PMD.
Line: 44
value = javaBeanDeser.deserialze(parser, fieldType, fieldInfo.name, fieldInfo.parserFeatures);
} else {
if (this.fieldInfo.format != null && fieldValueDeserilizer instanceof ContextObjectDeserializer) {
value = ((ContextObjectDeserializer) fieldValueDeserilizer) //
.deserialze(parser, fieldType,
fieldInfo.name,
fieldInfo.format,
fieldInfo.parserFeatures);
} else {
Reported by PMD.
Line: 50
fieldInfo.format,
fieldInfo.parserFeatures);
} else {
value = fieldValueDeserilizer.deserialze(parser, fieldType, fieldInfo.name);
}
}
if (parser.getResolveStatus() == DefaultJSONParser.NeedToResolve) {
DefaultJSONParser.ResolveTask task = parser.getLastResolveTask();
task.fieldDeserializer = this;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Issue69.java
4 issues
Line: 17
vo.b = vo.a;
String text = JSON.toJSONString(vo);
System.out.println(text);
}
@JSONType(serialzeFeatures={SerializerFeature.DisableCircularReferenceDetect})
public static class VO {
Reported by PMD.
Line: 11
public class Issue69 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.a = new Entry();
vo.b = vo.a;
String text = JSON.toJSONString(vo);
Reported by PMD.
Line: 11
public class Issue69 extends TestCase {
public void test_for_issue() throws Exception {
VO vo = new VO();
vo.a = new Entry();
vo.b = vo.a;
String text = JSON.toJSONString(vo);
Reported by PMD.
Line: 21
}
@JSONType(serialzeFeatures={SerializerFeature.DisableCircularReferenceDetect})
public static class VO {
private Entry a;
private Entry b;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/CurrencyTest_2.java
4 issues
Line: 17
vo.setValue(Currency.getInstance(Locale.CHINA));
vo.setValue1(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
JSON.parseObject(text, VO.class);
}
public static class VO {
Reported by PMD.
Line: 12
public class CurrencyTest_2 extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setValue(Currency.getInstance(Locale.CHINA));
vo.setValue1(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 12
public class CurrencyTest_2 extends TestCase {
public void test_0() throws Exception {
VO vo = new VO();
vo.setValue(Currency.getInstance(Locale.CHINA));
vo.setValue1(Currency.getInstance(Locale.CHINA));
String text = JSON.toJSONString(vo);
System.out.println(text);
Reported by PMD.
Line: 21
JSON.parseObject(text, VO.class);
}
public static class VO {
private Currency value;
private Currency value1;
public Currency getValue() {
Reported by PMD.
src/test/java/com/alibaba/json/bvt/JSONObjectTest5.java
4 issues
Line: 11
public class JSONObjectTest5 extends TestCase {
public void test() throws Exception {
JSONObject jsonObject = new JSONObject(3, true);
jsonObject.put("name", "J.K.SAGE");
jsonObject.put("age", 21);
jsonObject.put("msg", "Hello!");
JSONObject cloneObject = (JSONObject) jsonObject.clone();
Reported by PMD.
Line: 17
jsonObject.put("age", 21);
jsonObject.put("msg", "Hello!");
JSONObject cloneObject = (JSONObject) jsonObject.clone();
assertEquals(JSON.toJSONString(jsonObject), JSON.toJSONString(cloneObject));
}
}
Reported by PMD.
Line: 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import org.junit.Assert;
public class JSONObjectTest5 extends TestCase {
Reported by PMD.
Line: 7
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import junit.framework.TestCase;
import org.junit.Assert;
public class JSONObjectTest5 extends TestCase {
public void test() throws Exception {
JSONObject jsonObject = new JSONObject(3, true);
Reported by PMD.
src/test/java/com/alibaba/json/bvt/bug/Bug_for_set.java
4 issues
Line: 9
public class Bug_for_set extends TestCase {
public void test_set() throws Exception {
JSON.parseArray("Set[]");
}
public void test_treeset() throws Exception {
JSON.parseArray("TreeSet[]");
Reported by PMD.
Line: 9
public class Bug_for_set extends TestCase {
public void test_set() throws Exception {
JSON.parseArray("Set[]");
}
public void test_treeset() throws Exception {
JSON.parseArray("TreeSet[]");
Reported by PMD.
Line: 13
JSON.parseArray("Set[]");
}
public void test_treeset() throws Exception {
JSON.parseArray("TreeSet[]");
}
}
Reported by PMD.
Line: 13
JSON.parseArray("Set[]");
}
public void test_treeset() throws Exception {
JSON.parseArray("TreeSet[]");
}
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TimeZoneFieldTest.java
4 issues
Line: 14
public class TimeZoneFieldTest extends TestCase {
public void test_codec() throws Exception {
User user = new User();
user.setValue(TimeZone.getDefault());
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 24
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
Reported by PMD.
Line: 27
Assert.assertEquals(user1.getValue(), user.getValue());
}
public void test_codec_null() throws Exception {
User user = new User();
user.setValue(null);
SerializeConfig mapping = new SerializeConfig();
mapping.setAsmEnable(false);
Reported by PMD.
Line: 37
User user1 = JSON.parseObject(text, User.class);
Assert.assertEquals(user1.getValue(), user.getValue());
}
public static class User {
private TimeZone value;
Reported by PMD.
src/test/java/com/alibaba/json/bvt/TimestampTest.java
4 issues
Line: 27
SimpleDateFormat format = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
String text = "\"" + format.format(new Date(millis)) + "\"";
System.out.println(text);
Assert.assertEquals(new Timestamp(millis), JSON.parseObject("" + millis, Timestamp.class));
Assert.assertEquals(new Timestamp(millis), JSON.parseObject("\"" + millis + "\"", Timestamp.class));
Assert.assertEquals(new Timestamp(millis), JSON.parseObject(text, Timestamp.class));
Assert.assertEquals(new java.sql.Date(millis), JSON.parseObject(text, java.sql.Date.class));
Assert.assertEquals(new java.util.Date(millis), JSON.parseObject(text, java.util.Date.class));
Reported by PMD.
Line: 16
import com.alibaba.fastjson.JSON;
public class TimestampTest extends TestCase {
protected void setUp() throws Exception {
JSON.defaultTimeZone = TimeZone.getTimeZone("Asia/Shanghai");
JSON.defaultLocale = Locale.CHINA;
}
public void test_0 () throws Exception {
Reported by PMD.
Line: 21
JSON.defaultLocale = Locale.CHINA;
}
public void test_0 () throws Exception {
long millis = (System.currentTimeMillis() / 1000) * 1000;
SimpleDateFormat format = new SimpleDateFormat(JSON.DEFFAULT_DATE_FORMAT, JSON.defaultLocale);
format.setTimeZone(JSON.defaultTimeZone);
String text = "\"" + format.format(new Date(millis)) + "\"";
Reported by PMD.
Line: 28
format.setTimeZone(JSON.defaultTimeZone);
String text = "\"" + format.format(new Date(millis)) + "\"";
System.out.println(text);
Assert.assertEquals(new Timestamp(millis), JSON.parseObject("" + millis, Timestamp.class));
Assert.assertEquals(new Timestamp(millis), JSON.parseObject("\"" + millis + "\"", Timestamp.class));
Assert.assertEquals(new Timestamp(millis), JSON.parseObject(text, Timestamp.class));
Assert.assertEquals(new java.sql.Date(millis), JSON.parseObject(text, java.sql.Date.class));
Assert.assertEquals(new java.util.Date(millis), JSON.parseObject(text, java.util.Date.class));
}
Reported by PMD.
src/test/java/com/alibaba/json/bvt/DeprecatedClassTest.java
4 issues
Line: 11
@SuppressWarnings("deprecation")
public class DeprecatedClassTest extends TestCase {
@SuppressWarnings("resource")
public void test_0() throws Exception {
new DefaultExtJSONParser("");
new DefaultExtJSONParser("", ParserConfig.getGlobalInstance(), 1);
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 1);
}
Reported by PMD.
Line: 12
@SuppressWarnings("deprecation")
public class DeprecatedClassTest extends TestCase {
@SuppressWarnings("resource")
public void test_0() throws Exception {
new DefaultExtJSONParser("");
new DefaultExtJSONParser("", ParserConfig.getGlobalInstance(), 1);
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 1);
}
Reported by PMD.
Line: 18
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 1);
}
public void test_1() throws Exception {
new JSONSerializerMap().put(Object.class, null);
}
}
Reported by PMD.
Line: 18
new DefaultExtJSONParser("".toCharArray(), 0, ParserConfig.getGlobalInstance(), 1);
}
public void test_1() throws Exception {
new JSONSerializerMap().put(Object.class, null);
}
}
Reported by PMD.