|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectharpoon.ClassFile.Linker
harpoon.ClassFile.Relinker
public class Relinker
A Relinker
object is a Linker
where one
can globally replace references to a certain class with references
to another, different, class.
Field Summary | |
---|---|
protected Linker |
linker
|
Fields inherited from class harpoon.ClassFile.Linker |
---|
descCache |
Constructor Summary | |
---|---|
Relinker(Linker linker)
Creates a Relinker . |
Method Summary | |
---|---|
HClass |
createMutableClass(String name,
HClass template)
Creates a mutable class with the given name which is based on the given template class. |
protected HClass |
forDescriptor0(String descriptor)
Sub-classes will provide implementation for the forDescriptor0 method in order to implement
a linking strategy. |
protected HClass |
makeArray(HClass baseType,
int dims)
Allow Linker subclass to substitute a different (mutable?) |
void |
move(HMember hm,
HClass newDestination)
Move HMember hm from its declaring
class to some other class, newDestination . |
void |
relink(HClass oldClass,
HClass newClass)
Globally replace all references to oldClass with
references to newClass , which may or may not have
the same name. |
Methods inherited from class harpoon.ClassFile.Linker |
---|
forClass, forDescriptor, forName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Linker linker
Constructor Detail |
---|
public Relinker(Linker linker)
Relinker
.
Method Detail |
---|
protected HClass forDescriptor0(String descriptor)
Linker
forDescriptor0
method in order to implement
a linking strategy. This method is only passed descriptors for
class types; never array or primitive type descriptors.
(Hence neither primitive types or array types can be
re-linked, which might violate java language semantics.)
forDescriptor0
in class Linker
protected HClass makeArray(HClass baseType, int dims)
Linker
makeArray
in class Linker
public HClass createMutableClass(String name, HClass template)
createMutableClass
in class Linker
public void relink(HClass oldClass, HClass newClass)
oldClass
with
references to newClass
, which may or may not have
the same name. The following constraint must hold:oldClass.getLinker()==newClass.getLinker()==this
WARNING: the hasBeenModified()
method of
HClass
is not reliable after calling
relink()
if oldClass.getName()
is not the
same as newClass.getName()
. The value returned
by HClass.hasBeenModified()
will not reflect changes
due to the global replacement of oldClass
with
newClass
done by this relink()
.
public void move(HMember hm, HClass newDestination) throws DuplicateMemberException
HMember
hm
from its declaring
class to some other class, newDestination
. This
usually only makes sense if you're moving a member from a
class to its superclass, or vice-versa --- but we're not
enforcing this (full foot-shooting power granted). The
newDestination
class must not already have a
field named the same/method with the same signature as
hm
. All references to the member in the old class
will be re-directed to point to the member in the new class,
and in fact, upon return the given HMember
hm
will refer to the new member.
WARNING: make sure that any methods which refer to this
member have been converted to Bytecode form at least *before*
invoking move()
; otherwise field resolution will fail
when we are parsing the bytecode file (we don't keep any record
of the 'old' or 'canonical' name of the moved member).
DuplicateMemberException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |