Skip to content
Permalink
Browse files
6685: Parse more fields directly to primitive values
Reviewed-by: hirt
  • Loading branch information
Henrik Dafgård committed Feb 10, 2020
1 parent 6dd19dd commit c85d31b0f89dab2aecf80913313a8fa37ddbe09f
@@ -78,11 +78,7 @@

@Override
public Long getThreadId() {
/*
* NOTE: Parser currently creates thread ID as a quantity, which it probably shouldn't
* be. See TypeManager.createFieldReader(FieldElement, String).
*/
return ((Number) javaThreadId).longValue();
return (Long) javaThreadId;
}

@Override
@@ -603,11 +599,7 @@ public String getFormalDescriptor() {

@Override
public Integer getModifier() {
/*
* NOTE: Parser currently creates method modifier as a quantity, which it probably
* shouldn't be. See TypeManager.createFieldReader(FieldElement, String).
*/
return ((Number) modifiers).intValue();
return (Integer) modifiers;
}

@Override
@@ -647,20 +639,12 @@ public boolean equals(Object obj) {

@Override
public Integer getFrameLineNumber() {
/*
* NOTE: Parser currently creates frame line number as a quantity, which it probably
* shouldn't be. See TypeManager.createFieldReader(FieldElement, String).
*/
return ((Number) lineNumber).intValue();
return (Integer) lineNumber;
}

@Override
public Integer getBCI() {
/*
* NOTE: Parser currently creates byte code index as a quantity, which it probably
* shouldn't be. See TypeManager.createFieldReader(FieldElement, String).
*/
return ((Number) bytecodeIndex).intValue();
return (Integer) bytecodeIndex;
}

@Override
@@ -451,13 +451,16 @@ private IValueReader createFieldReader(FieldElement f, String valueType) throws
if (JfrInternalConstants.TYPE_IDENTIFIER_VALUE_INTERPRETATION.equals(valueType)) {
reader = new TypeIdentifierReader(typeIdentifier, f.unsigned);
} else {
IUnit unit = UnitLookup.getUnitOrNull(valueType);
/*
* FIXME: Currently we convert all numbers to quantities. This might not be ideal,
* for example for thread IDs. See multiple notes referring to this method in
* StructTypes.
*/
reader = new QuantityReader(typeIdentifier, unit == null ? UnitLookup.NUMBER_UNITY : unit, f.unsigned);
if (JfrInternalConstants.LINE_NUMBER_ID.equals(f.fieldIdentifier)
|| JfrInternalConstants.BCI_ID.equals(f.fieldIdentifier)
|| JfrInternalConstants.MODIFIERS_ID.equals(f.fieldIdentifier)
|| JfrInternalConstants.JAVA_THREAD_ID_ID.equals(f.fieldIdentifier)) {
reader = new PrimitiveReader(typeIdentifier);
} else {
IUnit unit = UnitLookup.getUnitOrNull(valueType);
reader = new QuantityReader(typeIdentifier, unit == null ? UnitLookup.NUMBER_UNITY : unit,
f.unsigned);
}
}
}
if (f.isStoredInPool()) {
@@ -40,4 +40,8 @@
public static final String BUFFER_LOST_TYPE_ID = "org.openjdk.jmc.flightrecorder.bufferlosttypeid"; //$NON-NLS-1$
public static final String TYPE_IDENTIFIER_VALUE_INTERPRETATION = "org.openjdk.jmc.flightrecorder.value_interpretation.type_identifier"; //$NON-NLS-1$

public static final String LINE_NUMBER_ID = "lineNumber"; //$NON-NLS-1$
public static final String BCI_ID = "bytecodeIndex"; //$NON-NLS-1$
public static final String MODIFIERS_ID = "modifiers"; //$NON-NLS-1$
public static final String JAVA_THREAD_ID_ID = "javaThreadId"; //$NON-NLS-1$
}

0 comments on commit c85d31b

Please sign in to comment.