Skip to content

Commit

Permalink
add testcase for issue #2392
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Apr 4, 2024
1 parent abd0220 commit eb59e0c
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.alibaba.fastjson2.issues_2300;

import com.alibaba.fastjson2.JSONB;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Constructor;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class Issue2392 {
@Test
public void test() throws Exception {
Class<?> clazz = Class.forName("kotlin.collections.EmptyList");
Constructor<?> constructor = clazz.getDeclaredConstructor();
constructor.setAccessible(true);
Object object = constructor.newInstance();
byte[] bytes = JSONB.toBytes(object, JSONWriter.Feature.WriteClassName);
Object parsed = JSONB.parseObject(bytes, Object.class, JSONReader.Feature.SupportAutoType);
assertEquals(clazz, parsed.getClass());
}
}

0 comments on commit eb59e0c

Please sign in to comment.