DataNucleus - Products
  History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ENHANCER-58
Type: Task Task
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Erik Bengtson
Reporter: Martin Kendall
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JPOX Enhancer

jdoGetManagedFieldCount: NullPointerException

Created: 27/Mar/06 04:24 PM   Updated: 09/Dec/06 06:11 PM
Component/s: BCEL Enhancer
Affects Version/s: 1.1.0-rc-1
Fix Version/s: 1.1.2

File Attachments: 1. Zip Archive ENHANCER-58.zip (1 kb)

Image Attachments:

1. UML Class diagram.jpg
(7 kb)
Environment: Windows XP, jdk1.5.0_05


 Description  « Hide
When loading a class in the middle of a hierarchy, we are receiving a java.lang.ExceptionInInitializerError.
To reproduce this we have created a simple test (Cclass extending Bclass extending Aclass and Aclass has a reference to Cclass), to simplify the test we are loading Bclass using Class.forName(). Please see attached test.

To get round this in the short term we have taken a local copy of the JPOX enhancer and changed it to output bytecode that pushes the classConfig.getNoOfManagedFields() onto the stack (as a constant) rather than get it to evaluate the static jdoFieldNames at runtime. This removes the initialization dependency.
Sadly, this does not adhere to the JDO2 spec (JPOX correctly generates the JDO 2 specified code), but this looks like this is one of those cases where matching the spec does not work all the time.

(See discussion in forum http://www.jpox.org/servlet/forum/viewthread?thread=3225)

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Martin Kendall - 27/Mar/06 04:34 PM
UML diagram showing Java model used to reproduce issue.

Andy Jefferson - 12/Apr/06 02:06 PM
Post by Erik in the forum thread
[quote]
JVM spec

2.11 Static Initializers
"Any static initializers declared in a class are executed when the class is initialized"

2.17.4 Initialization
A class or interface type T will be initialized immediately before one of the following occurs:

* T is a class and a static method of T is invoked.
[/quote]
so, it looks like a bug in the VM

Erik Bengtson - 25/Jun/06 05:27 PM
JPOX now generates

protected static int jdoGetManagedFieldCount()
{
return <number of fields>+<superclass>.jdoGetManagedFieldCount();
}