Create self-contained reflection library for determining serialization properties.

Description

Create a reusable library io.plooploop-introspection for reflectively determining an object's properties and creating new objects based on given properties.

It appears from that we'll need to implement SURF marshaling from scratch. We'll need to do all the Java reflection ourselves, in order to do things like:

  • discover properties

  • determine whether to use getters/setters or fields

  • check for annotations that ignore properties, change property names, etc.

Environment

None

Activity

Show:
Garret Wilson
August 5, 2017, 6:32 PM

Moreover I'm going to start referring to the project as "Ploop" instead of "PLOOP". This is more consistent with our other projects such as Csar and Rincl; it will correspond more directly to the Java variable naming of PloopXXX; and all-caps names cause confusion in general.

Garret Wilson
August 5, 2017, 6:19 PM

This project is being renamed to ploop-introspection. The initial repository is now publicly available at https://bitbucket.org/globalmentor/ploop-introspection .

Garret Wilson
August 3, 2017, 3:25 AM
Garret Wilson
August 1, 2017, 5:35 PM

One of the core functionalities of this library will be to determine property names and types from method names (e.g. the property name fooBar from getFooBar()). I have implemented such a thing various times, e.g. in com.globalmentor.java.Classes.

I finally downloaded the JavaBeans specification (even though JavaBeans is seldom used as-is nowadays), and discovered that there is a class java.beans.Introspector which does most of this work. Unfortunately Introspector is not included in the Android SDK (although it really doesn't matter in the short term).

A larger problem is correctly determining the property types in the presence of generics. As Tatu Saloranta (the founder of Jackson) describes in Why 'java.lang.reflect.Type' Just Does Not Cut It as Complete Type Definition and Java Type Erasure not a Total Loss -- use Java Classmate for resolving generic signatures, in some cases Java erases generics even situations for which the generic type has been restricted, although there are other approaches available for finding this information. Tatu has created the ClassMate project (which is actually used in Jackson, Hibernate, and others) for discovering type information, and ClassMate may therefore be a better fit ploop-pojo to use in determining properties than Introspector.

Assignee

Garret Wilson

Reporter

Garret Wilson

Labels

None

Time tracking

0m

Time remaining

24h

Components

Fix versions

Priority

Critical