[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bcel-user
Subject:    Re: class to JavaClass file
From:       "Juozas Baliuka" <baliuka () mwm ! lt>
Date:       2003-04-08 11:54:23
[Download RAW message or body]


Try "getResurce" too, possible it throws some exeptions, all exeptions are
ignored in "getResourceAsStream" it can "hidde" problem.


----- Original Message -----
From: "gaurav shankar" <shankargaurav@hotmail.com>
To: <bcel-user@jakarta.apache.org>
Cc: <baliuka@mwm.lt>
Sent: Monday, April 07, 2003 6:17 PM
Subject: Re: class to JavaClass file


>
>
> yes I extracted rt.jar and class file was right there, Its strange I
> modified few classes but fails to do that for later classes.
>
> I'll try JNI
>
> Thanks
>
> Gaurav
>
>
>
>
> >From: "Juozas Baliuka" <baliuka@centras.lt>
> >Reply-To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> >To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> >CC: <baliuka@mwm.lt>
> >Subject: Re: class to JavaClass file
> >Date: Mon, 7 Apr 2003 17:43:58 +0200
> >
> >
> >All classes from rt.jar must be vissible for system classloader,
> >Are you sure problematic classes are fom this jar ?
> >
> >BTW: try JNI if you need this for SUN's JVM only, it calls "hooks" before
> >to
> >load classes,I have never tried this,but it must be possible to
> >modify class in this hook (call some static method implemented with BCEL
> >from JNI).
> >
> >
> >----- Original Message -----
> >From: "gaurav shankar" <shankargaurav@hotmail.com>
> >To: <bcel-user@jakarta.apache.org>
> >Cc: <baliuka@mwm.lt>
> >Sent: Monday, April 07, 2003 8:35 AM
> >Subject: Re: class to JavaClass file
> >
> >
> > > I running my class loader which chages as stated by u.But it fails to
> >create
> > > inputstream of few java.rmi class. Im trying to load rmi program it
> >loaded
> > > few of rmi library files but then it fails, and strangely for
different
> >rmi
> > > programs it gives nullpointerexception at diff class files.
> > >
> > > Please advice, your advices have been of real help to me, I really
> > > appreciate that
> > >
> > > regards
> > > Gaurav Shankar
> > >
> > >
> > >
> > >
> > >
> > > >From: "Juozas Baliuka" <baliuka@mwm.lt>
> > > >Reply-To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > >To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > >Subject: Re: class to JavaClass file
> > > >Date: Wed, 2 Apr 2003 12:39:22 +0200
> > > >
> > > >
> > > >----- Original Message -----
> > > >From: "gaurav shankar" <shankargaurav@hotmail.com>
> > > >To: <bcel-user@jakarta.apache.org>
> > > >Sent: Wednesday, April 02, 2003 4:41 AM
> > > >Subject: Re: class to JavaClass file
> > > >
> > > >
> > > > > Hi,
> > > > > This is a part of my ClassLoader , at  the end of this section I
> >have
> > > >result
> > > > > ( an instance of Class ) which gets bytecode of system classes, I
> >want
> > > >to
> > > > > convert this into JavaClass. "object" in your example is an
instance
> >of
> > > > > Class or shall I say object and result of same type ..
> > > > >
> > > > >
> > > > > public synchronized Class loadClass(String className, boolean
> >resolveIt)
> > > > >     throws ClassNotFoundException {
> > > > >         Class result;
> > > > >         byte  classData[];
> > > > > JavaClass java_class;
> > > > >
> > > > >         System.out.println("        >>>>>> Load class :
> >"+className);
> > > > >
> > > > >         /* Check our local cache of classes */
> > > > >         result = (Class)classes.get(className);
> > > > >         if (result != null) {
> > > > >             System.out.println("        >>>>>> returning cached
> > > >result.");
> > > > >             return result;
> > > > >         }
> > > > >
> > > > >         /* Check with the primordial class loader */
> > > > >         try {
> > > > >          //   result = super.findSystemClass(className);
> > > >
> > > >      //find class file as  "SystemResource" and parse it:
> > > >       InputStream is  =
> > > >ClassLoader.getSystemResourceAsStream(className.replace('.','/') +
> > > >".class");
> > > >       JavaClass   jcls = new ClassParser(is,className).parse();
> > > >
> > > > > // >> I WANT TO CONVERT THIS result TO JavaClass <<<<
> > > >     byte bytes[]= jcls.getBytes();
> > > >      return defineClass(bytes,0,bytes.length);
> > > >  //possible it will work for system clsses, I have never tried it.
> > > >//you will have two class versions, one in "bootstrap" classloder and
> >one
> > > >in
> > > >your classloder.
> > > >//JNI and JVM hooks are designed for this use case.
> > > >
> > > > >
> > > > >         } catch (ClassNotFoundException e) {
> > > > >             System.out.println("        >>>>>> Not a system
> >class.");
> > > > >         }
> > > > >
> > > > >
> > > > >
> > > > > Thanks for your help , I really appreciate it
> > > > >
> > > > > Regards
> > > > > Gaurav Shankar
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > >From: "Juozas Baliuka" <baliuka@centras.lt>
> > > > > >Reply-To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > > > >To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > > > >Subject: Re: class to JavaClass file
> > > > > >Date: Tue, 1 Apr 2003 08:11:26 +0200
> > > > > >
> > > > > >
> > > > > >You can load class file as resource with system classloader, but
> >you
> > > >can
> > > > > >not
> > > > > >to define it twice in the same classloader:
> > > > > >
> > > > > >  JavaClass jclass =  new
> > > > >
> > > >
> >
>ClassParser(Object.class.getResource(Object.class.getName().replace('.','/'
> > > >)
> > > > > >+ ".class")),Object.class.getName());
> > > > > >
> > > > > >
> > > > > > > What I am trying to do is change in constant pool of every
class
> >my
> > > > > > > application loads (not all but that also includes some library
> > > >classes )
> > > > > >for
> > > > > > > that im trying to change instance of Class that
> >findSystemClass()
> > > > > >returns
> > > > > > > into that of JavaClass so that I can change in the constant
pool
> >and
> > > > > >then
> > > > > > > use defineClass on it. ClassParser converts DataInputStream
into
> > > > > >JavaClass,
> > > > > > > how can I make it to change Class into JavaClass.
> > > > > > >
> > > > > > > Thanks
> > > > > > > Gaurav Shankar
> > > > > > > CS Deptt , Rutgers University
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > >From: "Juozas Baliuka" <baliuka@mwm.lt>
> > > > > > > >Reply-To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > > > > > >To: "BCEL Users List" <bcel-user@jakarta.apache.org>
> > > > > > > >Subject: Re: class to JavaClass file
> > > > > > > >Date: Mon, 31 Mar 2003 17:25:44 +0200
> > > > > > > >
> > > > > > > >
> > > > > > > >Sometimes it can work on system classes too,
> > > > > > > >classloader can not define system class, but you can try
> >depricated
> > > > > > > >"defineClass(byte[] b, int pos, int len)" method, I am not
sure
> > > >this
> > > > > >will
> > > > > > > >work for classes like Object or String,
> > > > > > > >and it is no way to define classes for arrays.
> > > > > > > >
> > > > > > > >
> > > > > > > > > Hi,
> > > > > > > > > Im trying my class loader with BCEL, Im looking Constant
> >pool
> >of
> > > > > >each
> > > > > > > >class
> > > > > > > > > used by my application, even system classes, for that I
need
> >to
> > > > > >convert
> > > > > > > > > class file ( which I get as result of findSystemClass() )
> >and
> > > > > >convert
> > > > > >it
> > > > > > > >to
> > > > > > > > > JavaClass file.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > regards
> > > > > > > > >
> > > > > > > > > Gaurav Shankar
> > > > > > > > >
> > > > > > > > >
> > > >_________________________________________________________________
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > >
> > >---------------------------------------------------------------------
> > > > > > > > > To unsubscribe, e-mail:
> >bcel-user-unsubscribe@jakarta.apache.org
> > > > > > > > > For additional commands, e-mail:
> > > >bcel-user-help@jakarta.apache.org
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > >
>---------------------------------------------------------------------
> > > > > > > >To unsubscribe, e-mail:
> >bcel-user-unsubscribe@jakarta.apache.org
> > > > > > > >For additional commands, e-mail:
> >bcel-user-help@jakarta.apache.org
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> >_________________________________________________________________
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > >---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail:
bcel-user-unsubscribe@jakarta.apache.org
> > > > > > > For additional commands, e-mail:
> >bcel-user-help@jakarta.apache.org
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > >---------------------------------------------------------------------
> > > > > >To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> > > > > >For additional commands, e-mail:
bcel-user-help@jakarta.apache.org
> > > > > >
> > > > >
> > > > >
> > > > > _________________________________________________________________
> > > > > Vrroooom…… Fasten your seatbelts.
> > > > > http://server1.msn.co.in/msnSpecials/formula2003/index.asp Get set
> >for
> > > >F1
> > > > > 2003
> > > > >
> > > > >
> > > > >
> >---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> > > > > For additional commands, e-mail: bcel-user-help@jakarta.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> > > >For additional commands, e-mail: bcel-user-help@jakarta.apache.org
> > > >
> > >
> > >
> > > _________________________________________________________________
> > > War on Iraq. See latest update.
> > > http://server1.msn.co.in/completecoverage/bushvssaddam/ News, views
and
> >more
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: bcel-user-help@jakarta.apache.org
> > >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: bcel-user-help@jakarta.apache.org
> >
>
>
> _________________________________________________________________
> Say it now. Say it online. http://www.msn.co.in/ecards/ Send e-cards to
your
> love
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: bcel-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bcel-user-help@jakarta.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic