diff --git a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDefinition.java b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDefinition.java index 18c2bdd830..bc7f67708a 100644 --- a/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDefinition.java +++ b/ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDefinition.java @@ -36,9 +36,11 @@ public final class EnumDefinition extends SimpleDatatypeDefinition { private static final String UNKNOWN_ENUM = " (%s)"; //$NON-NLS-1$ + private static final String UNINITIALIZED = "UNINITIALIZED"; //$NON-NLS-1$ + private final IntegerDefinition fInteger; - private final @Nullable String fValue; + private @Nullable String fValue; // ------------------------------------------------------------------------ // Constructors @@ -59,9 +61,9 @@ public final class EnumDefinition extends SimpleDatatypeDefinition { public EnumDefinition(@NonNull EnumDeclaration declaration, IDefinitionScope definitionScope, @NonNull String fieldName, IntegerDefinition intValue) { super(declaration, definitionScope, fieldName); - fInteger = intValue; - fValue = declaration.query(fInteger.getValue()); + fValue = UNINITIALIZED; + } // ------------------------------------------------------------------------ @@ -75,6 +77,9 @@ public EnumDefinition(@NonNull EnumDeclaration declaration, * @return the value of the enum. */ public String getValue() { + if (fValue == UNINITIALIZED) { + fValue = getDeclaration().query(fInteger.getValue()); + } return fValue != null ? fValue : String.format(UNKNOWN_ENUM, getIntegerValue()); }