-
Notifications
You must be signed in to change notification settings - Fork 15
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
1 parent
9b3aa9a
commit 5e2768f
Showing
3 changed files
with
73 additions
and
63 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
71 changes: 71 additions & 0 deletions
71
luceedebug/src/main/java/luceedebug/coreinject/KlassMap.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,71 @@ | ||
package luceedebug.coreinject; | ||
|
||
import java.util.HashMap; | ||
|
||
import luceedebug.Config; | ||
import luceedebug.OriginalAndTransformedString; | ||
|
||
import com.sun.jdi.*; | ||
|
||
class KlassMap { | ||
/** | ||
* original -> original | ||
* | ||
* transformed -> canonicalized as per fs config | ||
*/ | ||
final public OriginalAndTransformedString sourceName; | ||
final public HashMap<Integer, Location> lineMap; | ||
private final ClassObjectReference objRef; | ||
|
||
final public ReferenceType refType; | ||
|
||
private KlassMap(Config config, ReferenceType refType) throws AbsentInformationException { | ||
objRef = refType.classObject(); | ||
|
||
String sourceName = refType.sourceName(); | ||
var lineMap = new HashMap<Integer, Location>(); | ||
|
||
for (var loc : refType.allLineLocations()) { | ||
lineMap.put(loc.lineNumber(), loc); | ||
} | ||
|
||
this.sourceName = new OriginalAndTransformedString( | ||
sourceName, | ||
Config.canonicalizeFileName(sourceName) | ||
); | ||
this.lineMap = lineMap; | ||
this.refType = refType; | ||
} | ||
|
||
boolean isCollected() { | ||
return objRef.isCollected(); | ||
} | ||
|
||
/** | ||
* May return null if ReferenceType throws an AbsentInformationException, which the caller | ||
* should interpret as "we can't do anything meaningful with this file" | ||
*/ | ||
static KlassMap maybeNull_tryBuildKlassMap(Config config, ReferenceType refType) { | ||
try { | ||
return new KlassMap(config, refType); | ||
} | ||
catch (AbsentInformationException e) { | ||
return null; | ||
} | ||
catch (Throwable e) { | ||
e.printStackTrace(); | ||
System.exit(1); | ||
} | ||
|
||
// unreachable | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object e) { | ||
if (e instanceof KlassMap) { | ||
return ((KlassMap)e).sourceName.equals(this.sourceName); | ||
} | ||
return false; | ||
} | ||
} |
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