You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by "Albrecht, Matt" <ma...@zilliant.com> on 2002/02/04 21:39:49 UTC

RE: [PROPOSAL] 'redefine' task that uses JDK 1.4/JPDA class redef inition

Just a note: this weekend I was working on a pet project which uses JPDA.  I
was running with Sun JDK 1.4 beta 2, on Windows 2000, when I noticed that
the capability for redefinition is not enabled.  I'm not sure as to the
result with the current RC1, but this means that even if you do run this
with JDK 1.4, you're not guaranteed to have it work.

-Matt Albrecht 

> -----Original Message-----
> From: burton@openprivacy.org [mailto:burton@openprivacy.org]
> Sent: Sunday, February 03, 2002 3:46 PM
> To: ant-dev@jakarta.apache.org
> Subject: [PROPOSAL] 'redefine' task that uses JDK 1.4/JPDA class
> redefinition
> 
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> OK.
> 
> Has anyone read about the JPDA 1.4 enhancements that have 
> made it into JDK 1.4:
> 
> http://java.sun.com/j2se/1.4/docs/guide/jpda/enhancements.html
> 
> I am specifically talking about class redefinition.  AKA the 
> ability to
> recompile and update classes within a running JVM.
> 
> This is done through JPDA and should support any application 
> that runs within
> JDK 1.4.
> 
> Some applications like Tomcat have class reloading built into 
> them.  This is
> primarily due to the fact that Java has not been able to 
> redefine classes at
> runtime.  
> 
> What I want to do is build a new ant task named 'redefine' 
> that takes a
> directory of .class files, compares it to a directory of 
> deployed class files
> (if available) and redefines them.
> 
> So for example one could:
> 
> <redefine host="localhost" port="2112">
> 
>     <new-classes>
> 
>         <fileset dir="../bin/classes" includes="**/*.class"/>
> 
>     </new-classes>        
> 
> </redefine>
> 
> This would connect to localhost:2112 with JPDA and redefine 
> every class under
> ../bin/classes.
> 
> This isn't as easy as it sounds... there are some issues.
> 
> Specifically if you have singleton classes, these will not be 
> reloaded.  In
> order to do this you have to pop entries off the stack before 
> this class was
> used.  
> 
> Obviously in a lot of situations this is not desirable.  We 
> should have the
> ability to enable/disable this via pop-frames="false|true" 
> (should be false by
> default)
> 
> This should provide a significant increase in functionality 
> for both server
> applications and developers.  
> 
> Developers could have compile, redefine, and test (with 
> cactus or RPC style
> code) within seconds without having to wait for their ENTIRE 
> application
> reload.  Application server admins will be able to redefine 
> necessary code
> without having to restart their application (think availability).
> 
> Thought?
> 
> I think this is a good idea.  Of course I will contribute 
> this to Apache if it
> is requested.
> 
> The only other drawback is that this will require JDK 1.4 to 
> compile.  It might
> be a good idea to put this under a CONTRIB directory.
> 
> Kevin
> 
> - -- 
> Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, 
> burtonator@acm.org )
>              Location - San Francisco, CA, Cell - 415.595.9965
>         Jabber - burtonator@jabber.org,  Web - 
> http://relativity.yi.org/
> 
> Windows is easy to learn and hard to use, while *nix is hard 
> to learn but easy
> to use. 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt
> 
> iD8DBQE8Xa+YAwM6xb2dfE0RAkzYAKC/dLJws35YStdaVHTCdmnRGT92pgCeJaG6
> 260llFeSASt3UjOIPrhk4z8=
> =j4+F
> -----END PGP SIGNATURE-----
> 
> --
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [PROPOSAL] 'redefine' task that uses JDK 1.4/JPDA class redef inition

Posted by "Kevin A. Burton" <bu...@openprivacy.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

"Albrecht, Matt" <ma...@zilliant.com> writes:

> Just a note: this weekend I was working on a pet project which uses JPDA.  I
> was running with Sun JDK 1.4 beta 2, on Windows 2000, when I noticed that the
> capability for redefinition is not enabled.  I'm not sure as to the result
> with the current RC1, but this means that even if you do run this with JDK
> 1.4, you're not guaranteed to have it work.
<snip/>

There are ways around that

if ( vm.canRedefineClasses()  == false)
    throw new BuildException( "The target VM can not redefine classes." );

Redefine should just throw an exception on Windows 2000

Strange. UInder Linux I have:

 [redefine] Target VM canAddMethod : false
 [redefine] Target VM canUnrestrictedlyRedefineClasses : false
 [redefine] Target VM canPopFrame : true

I wonder if anyone on other platforms has canAddMethod or
canUnrestrictedlyRedefineClasses.

It would be nice to have someone with SUN whom I could talk to about this but
there is no JPDA mailing list.

I am sick of Java being so closed :(

Kevin
 
- -- 
Kevin A. Burton ( burton@apache.org, burton@openprivacy.org, burtonator@acm.org )
             Location - San Francisco, CA, Cell - 415.595.9965
        Jabber - burtonator@jabber.org,  Web - http://relativity.yi.org/

Who wants to be responsible?  Every time something goes wrong they say 'who's
responsible for this?'.
  -- Jerry Seinfeld
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Get my public key at: http://relativity.yi.org/pgpkey.txt

iD8DBQE8Xv9GAwM6xb2dfE0RAsxxAJ0TuHuUZDyWBSSGX2hLWPVefbbELACfRWmU
eyg3icRA6US9VsncqZLAr7Y=
=8+Dd
-----END PGP SIGNATURE-----

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>