RFR: 7439: Introduced IConstantPoolExtension for Constant Pools [v5]

Jean-Philippe Bempel jpbempel at openjdk.java.net
Sun Nov 21 21:45:10 UTC 2021


On Sat, 20 Nov 2021 13:08:28 GMT, Michael Südkamp <duke at openjdk.java.net> wrote:

>> hello @docwarems 
>> My test is focusing on event Types that referencing constants.
>> 
>> when using the callback:
>> 
>> Object constantRead(long constantIndex, Object constant, String eventTypeId) {
>> 	return constant;
>> }
>> 
>> you should look at constant argument that should be what you would like to de-obfuscate and return a translated value instead of the original one:
>> 
>> 
>> Object constantRead(long constantIndex, Object constant, String eventTypeId) {
>> 	return deobfuscate(constant);
>> }
>
>> My test is focusing on event Types that referencing constants.
> 
> Yeah, that's more or less what I expected. Maybe I'm unable to find my constant of interest in the mass of other classes. Could you provide a breakpoint condition for the breakpoint condition shown below which would stop at a class "fr.jpbempel.HelloWorld"?
> 
> ![grafik](https://user-images.githubusercontent.com/29914148/142727338-e7d0e27d-1c21-409e-a543-a4826b45bfbf.png)

Hey, @docwarems 

I have created a custom event:


package com.bempel.events;

import jdk.jfr.Event;
import jdk.jfr.Label;
import jdk.jfr.Name;

@Name("com.bempel.events.MyEvent")
@Label("MyEvent")
public class MyEvent extends Event {
	@Label("message")
	public String message;
}


I have used like this:

MyEvent myEvent = new MyEvent();
myEvent.message = "showVetList " + uuid;
myEvent.commit();


I have recording with this event in it:

<img width="979" alt="Screenshot 2021-11-21 at 22 31 13" src="https://user-images.githubusercontent.com/4610701/142779645-585707c9-b345-4171-9a5a-d40c014d835c.png">

You can look at constant pools :

in `java.lang.Class`
<img width="562" alt="Screenshot 2021-11-21 at 22 32 25" src="https://user-images.githubusercontent.com/4610701/142779684-e2e78175-1529-43d9-8dbd-a5c2550f57cb.png">

but also in `jdk.Types.Symbol`:
<img width="570" alt="Screenshot 2021-11-21 at 22 32 58" src="https://user-images.githubusercontent.com/4610701/142779819-83333f9a-3fde-48fd-ac11-38f4427054f9.png">


in debugging ConstantPoolExtensionTest:
<img width="1424" alt="Screenshot 2021-11-21 at 22 34 38" src="https://user-images.githubusercontent.com/4610701/142779795-38f03d70-06fb-4659-aa8c-045bac354bc4.png">

But it's a little bit complex because:
a class constant is not having directly the name of the class but reference another symbol constant for that
see:
https://github.com/openjdk/jmc/blob/master/core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/internal/parser/v1/StructTypes.java#L277-L287

That's why it may have more sense to look for the symbol constant instead of directly the class constant.

-------------

PR: https://git.openjdk.java.net/jmc/pull/333


More information about the jmc-dev mailing list