cyberborean / rdfbeans

Java persistence with RDF
Other
11 stars 12 forks source link

Dynamic proxies should return default values for primitive type properties #41

Closed cyberborean closed 4 years ago

cyberborean commented 4 years ago

In the current implementation, reading a primitive type property of a dynamic proxy instantiated from a RDFBean interface causes NullPointerException if the property has not been initialized. This is due to the InvocationHandler.invoke() contract:

If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance.

We may want to return the default values for primitive type properties instead of throwing a NPE (see https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html).