Bug 116922 - private methods weaved into target classes result in mangled method names
Summary: private methods weaved into target classes result in mangled method names
Status: RESOLVED WONTFIX
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M4   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-17 14:44 EST by Shawn Shyh CLA
Modified: 2005-11-19 12:14 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Shyh CLA 2005-11-17 14:44:08 EST
My problem is similar to bug #73507, but I have different request.

If you make attempt to weave private methods into target classes, the method 
names are mangled. I understand why you'd want to mangle them (to avoid 
collisions), but is there a way to turn it off (possibly via system property)?

We are attempting weave in a custom writeObject(ObjectOutputStream) method 
implementation for java serialization. The java 1.4 spec requires this method 
to be declared private. It looks for the existence of this private method and 
invokes it if it exists. Unfortunately, because the method name is mangled, it 
doesn't find the method by its appropriate name.

We're doing something like the following:

aspect X
{
    private writeObject(ObjectOutputStream out)
    {

    }
}
Comment 1 Shawn Shyh CLA 2005-11-17 14:48:00 EST
Sorry about that, committed prematurely.
Let me finish the description:

We're doing something like the following:

aspect X
{
    private writeObject(ObjectOutputStream out)
    {
       ...
    }
}

When you weave this into target classes, the name of the private methods is 
something like:
"ajc$interMethodDispatch2
$com_wily_util_persistence_perst_PersistenceAspect$writeObject"

This is clearly not recognized by the java serialization code as the 
writeObject method.

Is there anyway to customize the mangling or to turn it off?

-Shawn
Comment 2 Adrian Colyer CLA 2005-11-19 12:14:45 EST
As discussed on the list, you could use Externalizable in this case? 

AspectJ has no plans to allow customization of its internal code generation strategies in the near future 
(quite probably ever). Also, a private ITD means private with respect to the aspect, not private with respect 
to the target type. 

I'm going to close this report out - the Java class library design in this area should be in a public hall of 
shame somewhere, but we're not going to do unnatural things to AspectJ to work around it!