Skip to content

(WIP) Work towards #4907 on 3.x: reduce introspection for "java.*" classes (and maybe others too) #5137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 22 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0b769e2
Work towards #4907: reduce introspection for "java.*" classes (and ma…
cowtowncoder May 3, 2025
dd9e1ea
fix
cowtowncoder May 3, 2025
aa3bd02
...
cowtowncoder May 3, 2025
fde4ae4
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 3, 2025
86a1251
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 3, 2025
7666a3e
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 7, 2025
d1ea337
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 7, 2025
c984b7b
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 7, 2025
e234c39
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 8, 2025
2f76294
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 9, 2025
702d595
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 13, 2025
c0ef5ab
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 14, 2025
5d1b0c9
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 20, 2025
1432d8f
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 21, 2025
1fe74d6
...
cowtowncoder May 21, 2025
700ea03
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 21, 2025
0d5916f
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 21, 2025
9531d02
Minor addition to test
cowtowncoder May 21, 2025
939701f
...
cowtowncoder May 21, 2025
1ed6b90
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 21, 2025
5cf9fef
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 22, 2025
f3a6890
Merge branch '3.x' into tatu/3.0/4907-reduce-java-introspection
cowtowncoder May 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/main/java/tools/jackson/databind/BeanDescription.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,11 @@ public AnnotatedClass getClassInfo() {
@Override
public BeanDescription get() {
if (_beanDesc == null) {
//if (true) throw new Error("Gotcha!");
// To test without caching, uncomment:
//return _construct(_type, getClassInfo());
return _construct(_type, getClassInfo());

_beanDesc = _construct(_type, getClassInfo());
//_beanDesc = _construct(_type, getClassInfo());
}
return _beanDesc;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/tools/jackson/databind/DatabindContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -322,13 +322,13 @@ public BeanDescription.Supplier lazyIntrospectBeanDescription(JavaType type) {
return new BeanDescription.LazySupplier(getConfig(), type) {
@Override
protected BeanDescription _construct(JavaType forType, AnnotatedClass ac) {
// System.out.println("lazyIntrospectBeanDescription.beanDesc("+forType+")");
System.out.println("lazyIntrospectBeanDescription.beanDesc("+forType+")");
return introspectBeanDescription(forType);
}

@Override
protected AnnotatedClass _introspect(JavaType forType) {
// System.out.println("lazyIntrospectBeanDescription.annotatedClass("+forType+")");
System.out.println("lazyIntrospectBeanDescription.annotatedClass("+forType+")");
return introspectClassAnnotations(forType);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public JsonFormat.Value getFormatOverrides() {
*/
protected void collectAll()
{
//System.out.println(" PojoPropsCollector.collectAll() for "+_classDef.getRawType().getName());
System.out.println(" PojoPropsCollector.collectAll() for "+_classDef.getRawType().getName());
_potentialCreators = new PotentialCreators();

// First: gather basic accessors
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package tools.jackson.databind.misc;

import org.junit.jupiter.api.Test;

import tools.jackson.databind.*;
import tools.jackson.databind.testutil.DatabindTestUtil;

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

import java.util.Arrays;
import java.util.List;

public class Reflection4907Jackson3Test extends DatabindTestUtil
{
static class SqlDatePojo {
public String name;
public java.sql.Date date;
public List<String> tags;

public SqlDatePojo() {
}

public SqlDatePojo(String name, java.sql.Date date, String... tags) {
this.name = name;
this.date = date;
this.tags = Arrays.asList(tags);
}

public SqlDatePojo(java.sql.Date date) {
this.date = date;
}

public java.sql.Date getDate() {
return date;
}

public void setDate(java.sql.Date date) {
this.date = date;
}

public List<String> getTags() {
return tags;
}
}

private final ObjectMapper MAPPER = newJsonMapper();

@Test
public void test4907ReadPojo() throws Exception {
System.err.println("<testReadPojo>");
SqlDatePojo pojo = MAPPER.readValue(a2q("{'date':'2000-01-01', 'name':'foo'}"),
SqlDatePojo.class);
System.err.println("</testReadPojo>");
assertNotNull(pojo);
}

@Test
public void test4907WritePojo() throws Exception {
System.err.println("<testWritePojo>");
String json = MAPPER.writeValueAsString(new SqlDatePojo("foobar",
java.sql.Date.valueOf("2000-01-01"), "abc", "def"));
System.err.println("</testWritePojo>");
assertNotNull(json);
}
/*

@Test
public void test4907ReadTags() throws Exception {
System.err.println("<testReadTags>");
List<?> tags = MAPPER.readValue(a2q("['abc', 'def']"),
List.class);
System.err.println("</testReadTags>");
assertNotNull(tags);
}

@Test
public void test4907WriteTags() throws Exception {
System.err.println("<testWriteTags>");
String json = MAPPER.writeValueAsString(Arrays.asList("abc", "def"));
System.err.println("</testWriteTags>");
assertNotNull(json);
}
*/

/*
@Test
public void test4907ReadDate() throws Exception {
System.err.println("<testReadDate>");
java.sql.Date date = MAPPER.readValue(a2q("'2000-01-01'"),
java.sql.Date.class);
System.err.println("</testReadDate>");
assertNotNull(date);
}

@Test
public void test4907WriteDate() throws Exception {
System.err.println("<testWriteDate>");
String json = MAPPER.writeValueAsString(java.sql.Date.valueOf("2000-01-01"));
System.err.println("</testWriteDate>");
assertNotNull(json);
}
*/
}