Details
- 
        Type: New Feature New Feature
- 
        Status: Closed Closed
- 
            Priority: Major Major
- 
            Resolution: Fixed
- 
            Affects Version/s: 0.1
- 
            Fix Version/s: 1.2
- 
            Component/s: Compatibility
- 
            Labels:None
Description
Tip from Håkan Råberg at http://jroller.com/page/cv/20040310#wicked_reflection_tip:
It's done like this in the IBM JDK: 
From the IBM ObjectInputStream.java: 
/* Allocate a new object for the specified class
- Native since newInstance may not be able to find a zero arg constructor.
 */
 private static native Object allocateNewObject(Class aclass, Class initclass) throws InstantiationException, IllegalAccessException;
Example how to use it to create an Object without default ctor:
Method method = ObjectInputStream.class.getDeclaredMethod("allocateNewObject", new Class[]
{Class.class, Class.class});
method.setAccessible(true);
Locale l= (Locale) method.invoke(null, new Object[]
);



Can you comment on this, Joe? I have IBM JDK 1.4.2 running on Linux in Enhanced Mode.