-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
146 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/javgent/executor/bytecode/abstractdefault/AbstractDefaultSignatureWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package javgent.executor.bytecode.abstractdefault; | ||
|
||
import javgent.executor.bytecode.clazz.CurrentClassController; | ||
import javgent.executor.bytecode.clazz.util.InnerClassTypeResolver; | ||
|
||
public abstract class AbstractDefaultSignatureWriter extends AbstractClassBasedSignatureWriter { | ||
|
||
protected AbstractDefaultSignatureWriter(CurrentClassController controller) { | ||
super(controller); | ||
} | ||
|
||
@Override | ||
public void visitInnerClassType(String name) { | ||
var newName = InnerClassTypeResolver.resolve(controller, name); | ||
|
||
super.visitInnerClassType(newName); | ||
} | ||
|
||
@Override | ||
public void visitTypeVariable(String name) { | ||
var newName = controller.findNameByObfNameOrReturn(name); | ||
|
||
super.visitTypeVariable(newName); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/javgent/executor/bytecode/abstractdefault/AbstractDescriptorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package javgent.executor.bytecode.abstractdefault; | ||
|
||
import javgent.executor.bytecode.clazz.CurrentClassController; | ||
import org.objectweb.asm.signature.SignatureWriter; | ||
import org.slf4j.Logger; | ||
|
||
public abstract class AbstractDescriptorWriter extends SignatureWriter { | ||
|
||
protected CurrentClassController controller; | ||
protected Logger log; | ||
|
||
protected AbstractDescriptorWriter(CurrentClassController controller, Logger log) { | ||
this.controller = controller; | ||
this.log = log; | ||
} | ||
|
||
@Override | ||
public void visitClassType(String name) { | ||
var newName = controller.findNameByObfNameOrReturn(name); | ||
|
||
super.visitClassType(newName); | ||
} | ||
|
||
@Override | ||
public void visitFormalTypeParameter(String name) { | ||
log.warn("Visiting not implemented method 'visitFormalTypeParameter'! name='{}'", name); | ||
super.visitFormalTypeParameter(name); | ||
} | ||
|
||
@Override | ||
public void visitInnerClassType(String name) { | ||
log.warn("Visiting not implemented method 'visitInnerClassType'! name='{}'", name); | ||
super.visitInnerClassType(name); | ||
} | ||
|
||
@Override | ||
public void visitTypeVariable(String name) { | ||
log.warn("Visiting not implemented method 'visitTypeVariable'! name='{}'", name); | ||
super.visitTypeVariable(name); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 3 additions & 29 deletions
32
src/main/java/javgent/executor/bytecode/clazz/sub/method/visitor/MethodDescriptorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 3 additions & 36 deletions
39
src/main/java/javgent/executor/bytecode/clazz/sub/method/visitor/MethodSignatureWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/javgent/executor/bytecode/clazz/visitor/RecordDescriptorWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package javgent.executor.bytecode.clazz.visitor; | ||
|
||
import javgent.executor.bytecode.abstractdefault.AbstractDescriptorWriter; | ||
import javgent.executor.bytecode.clazz.CurrentClassController; | ||
import org.objectweb.asm.signature.SignatureReader; | ||
import org.objectweb.asm.signature.SignatureWriter; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class RecordDescriptorWriter extends AbstractDescriptorWriter { | ||
|
||
private static final Logger Log = LoggerFactory.getLogger(RecordDescriptorWriter.class); | ||
|
||
public RecordDescriptorWriter(CurrentClassController controller) { | ||
super(controller, Log); | ||
} | ||
|
||
public static String convert(CurrentClassController controller, String descriptor) { | ||
var writer = new RecordDescriptorWriter(controller); | ||
|
||
new SignatureReader(descriptor).accept(writer); | ||
|
||
return writer.toString(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/javgent/executor/bytecode/clazz/visitor/RecordSignatureWriter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package javgent.executor.bytecode.clazz.visitor; | ||
|
||
import javgent.executor.bytecode.abstractdefault.AbstractDefaultSignatureWriter; | ||
import javgent.executor.bytecode.clazz.CurrentClassController; | ||
import org.objectweb.asm.signature.SignatureReader; | ||
|
||
public class RecordSignatureWriter extends AbstractDefaultSignatureWriter { | ||
|
||
public RecordSignatureWriter(CurrentClassController controller) { | ||
super(controller); | ||
} | ||
|
||
public static String convert(CurrentClassController currentClassController, String signature) { | ||
if(signature == null) | ||
return null; | ||
|
||
var writer = new RecordSignatureWriter(currentClassController); | ||
|
||
new SignatureReader(signature).accept(writer); | ||
|
||
return writer.toString(); | ||
} | ||
} |