Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-dev] Bug#36430: Xreweavable now checked in.


Hi,

Xreweavable support is now checked in to CVS.

To summarise the feature:  if you supply -Xreweavable when invoking ajc
then although the class files produced will be woven, they can be rewoven
on a later invocation of ajc.  Reweavable class files are larger than their
non reweavable variants.  The rules are:

- -Xreweavable puts the weaver in reweavable mode.  A weaver in reweavable mode
  produces reweavable class files.
- A weaver *NOT* in reweavable mode can understand reweavable classes and use
  them, but when they are written out again by that weaver, the reweavable
  information will be not be included.
- If you attempt to reweave a class, any aspects that previously touched that
  class through advice or intertype declarations need to be accessible by the
  weaver, otherwise the reweave is unpredictable.
- If the size of the reweavable classes proves to be a problem for you, you can
  specify -Xreweavable:compress which attempts (at the cost of performance) to
  compress the reweavable information stored in the reweavable classes.

Finally, see below for a typical interaction sequence when using -Xreweavable
from the command line.

Andy.
--
Andy Clement
AspectJ/AJDT Development

================================================
Interacting with XReweavable on the tjp demo:


# Compile the code normally
C:\aspectj1.1\doc\examples\tjp>ajc -d output *.java

# How big are the classes?
C:\aspectj1.1\doc\examples\tjp>dir *.class /s

 Directory of C:\aspectj1.1\doc\examples\tjp\output\tjp
24/02/2004  09:25             5,759 Demo.class
24/02/2004  09:25             4,618 GetInfo.class
             
C:\aspectj1.1\doc\examples\tjp>cd output

# Try a binary weave using those files, it fails
C:\aspectj1.1\doc\examples\tjp\output>ajc -inpath .
C:\aspectj1.1\doc\examples\tjp\GetInfo.java:0 class 'tjp.GetInfo' is already
woven and has not been built with -Xreweavable
C:\aspectj1.1\doc\examples\tjp\output\tjp\Demo.java:0 class 'tjp.Demo' is
already woven and has not been built with -Xreweavable

2 errors

C:\aspectj1.1\doc\examples\tjp\output>cd ..

# Build reweavable classes
C:\aspectj1.1\doc\examples\tjp>ajc -d output *.java -Xreweavable

# How big are they now?
C:\aspectj1.1\doc\examples\tjp>dir *.class /s

 Directory of C:\aspectj1.1\doc\examples\tjp\output\tjp
24/02/2004  09:25             7,169 Demo.class
24/02/2004  09:25             9,024 GetInfo.class


# Build reweavable classes optimized with compressed internal data
C:\aspectj1.1\doc\examples\tjp>ajc -d output *.java -Xreweavable:compress


# How big are they now?
C:\aspectj1.1\doc\examples\tjp>dir *.class /s

 Directory of C:\aspectj1.1\doc\examples\tjp\output\tjp
24/02/2004  09:26             6,529 Demo.class
24/02/2004  09:26             6,726 GetInfo.class


C:\aspectj1.1\doc\examples\tjp>cd output


# Try a binary weave - with verbose output - it succeeds
C:\aspectj1.1\doc\examples\tjp\output>ajc -verbose -inpath .
zipfile classpath entry does not exist:
  C:\Program Files\Java\j2re1.4.2_01\lib\i18n.jar
zipfile classpath entry does not exist:
  C:\Program Files\Java\j2re1.4.2_01\lib\charsets.jar
directory classpath entry does not exist:
  C:\Program Files\Java\j2re1.4.2_01\classes
weaving
might need to weave [UnwovenClassFile(
   C:\aspectj1.1\doc\examples\tjp\output\tjp\Demo.class, tjp.Demo),
 UnwovenClassFile(
   C:\aspectj1.1\doc\examples\tjp\output\tjp\GetInfo.class, tjp.GetInfo)](world=true)
processing reweavable type tjp.Demo: tjp\Demo.java
successfully verified type tjp.GetInfo exists.  Originates from
  C:\aspectj1.1\doc\examples\tjp\GetInfo.java
processing reweavable type tjp.GetInfo: C:\aspectj1.1\doc\examples\tjp\GetInfo.java


# Run the code
C:\aspectj1.1\doc\examples\tjp\output>java tjp.Demo
Intercepted message: foo
in class: tjp.Demo
Arguments:
  0. i : int = 1
  1. o : java.lang.Object = tjp.Demo@6eb38a
Running original method:

Demo.foo(1, tjp.Demo@6eb38a)

  result: null
Intercepted message: bar
in class: tjp.Demo
Arguments:
  0. j : java.lang.Integer = 3
Running original method:

Demo.bar(3)

  result: Demo.bar(3)
Demo.bar(3)



# How big now?  The reweavable info was removed on last
# call to ajc as -Xreweavable wasn't supplied.
C:\aspectj1.1\doc\examples\tjp\output>dir *.class /s

 Directory of C:\aspectj1.1\doc\examples\tjp\output\tjp
24/02/2004  09:26             5,759 Demo.class
24/02/2004  09:26             4,618 GetInfo.class



# Finally, lets do try an illegal reweave operation - lets delete
# GetInfo.class which is required for reweaving of Demo.class
# to be valid

C:\aspectj1.1\doc\examples\tjp>ajc -d output -Xreweavable *.java

C:\aspectj1.1\doc\examples\tjp>cd output

C:\aspectj1.1\doc\examples\tjp\output>erase tjp\GetInfo.class

C:\aspectj1.1\doc\examples\tjp\output>ajc -inpath .
C:\aspectj1.1\doc\examples\tjp\output\tjp\Demo.java:0 type tjp.GetInfo is needed
 by reweavable type tjp.Demo

1 error

C:\aspectj1.1\doc\examples\tjp\output>

Back to the top