harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib][lang] Is it possible to new an object without invoking any constructor?
Date Thu, 15 Nov 2007 05:23:29 GMT
On Nov 15, 2007 1:08 PM, Tony Wu <wuyuehao@gmail.com> wrote:

> If you have an object already and it is cloneable, you can clone it
> without invoking any constructor :)


Hi Tony,

No, I don't have an object... I only have the definition of the class... I'm
looking for a method whose behavior is similar as

Object newNullObject(Class c)  {
   get a constructor
   new an object
   set all fields to null/0/false
   return the instance; // the object is like the initial state of
de-serialize as Nathan pointed out.
}

>
>
> On 11/15/07, Andrew Zhang <zhanghuangzhu@gmail.com> wrote:
> > Hi,
> >
> > Is it possible to new an object without invoking any constructor? I know
> the
> > question is a bit weird. What I want is to create an object with all
> > null/default value for its fields.
> > Reseting all fields to null by reflection is a possible solution, but is
> > there any existing special method (no matter it's low level or Harmony
> > specific) which can achieve this goal?
> > Thanks!
> >
> >
> > --
> > Best regards,
> > Andrew Zhang
> >
> > http://zhanghuangzhu.blogspot.com/
> >
>
>
> --
> Tony Wu
> China Software Development Lab, IBM
>



-- 
Best regards,
Andrew Zhang

http://zhanghuangzhu.blogspot.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message