|
1 | 1 | package com.datadog.debugger.instrumentation; |
2 | 2 |
|
3 | | -import static com.datadog.debugger.instrumentation.ASMHelper.extractSuperClass; |
4 | 3 | import static com.datadog.debugger.instrumentation.ASMHelper.getStatic; |
5 | 4 | import static com.datadog.debugger.instrumentation.ASMHelper.invokeConstructor; |
6 | 5 | import static com.datadog.debugger.instrumentation.ASMHelper.invokeStatic; |
@@ -1136,51 +1135,13 @@ private static List<FieldNode> extractStaticFields( |
1136 | 1135 | } |
1137 | 1136 | } |
1138 | 1137 | } |
1139 | | - if (!Config.get().isDynamicInstrumentationInstrumentTheWorld()) { |
1140 | | - // Collects inherited static fields only if the ITW mode is not enabled |
1141 | | - // because it can lead to LinkageError: attempted duplicate class definition |
1142 | | - // for example, when a probe is located in method overridden in enum element |
1143 | | - addInheritedStaticFields(classNode, classLoader, limits, results, fieldCount); |
1144 | | - } |
| 1138 | + // Collecting inherited static fields is problematic because it some cases can lead to |
| 1139 | + // LinkageError: attempted duplicate class definition |
| 1140 | + // as we force to load a class to get the static fields in a different order than the JVM |
| 1141 | + // for example, when a probe is located in method overridden in enum element |
1145 | 1142 | return results; |
1146 | 1143 | } |
1147 | 1144 |
|
1148 | | - private static void addInheritedStaticFields( |
1149 | | - ClassNode classNode, |
1150 | | - ClassLoader classLoader, |
1151 | | - Limits limits, |
1152 | | - List<FieldNode> results, |
1153 | | - int fieldCount) { |
1154 | | - String superClassName = extractSuperClass(classNode); |
1155 | | - while (!superClassName.equals(Object.class.getTypeName())) { |
1156 | | - Class<?> clazz; |
1157 | | - try { |
1158 | | - clazz = Class.forName(superClassName, false, classLoader); |
1159 | | - } catch (ClassNotFoundException ex) { |
1160 | | - break; |
1161 | | - } |
1162 | | - try { |
1163 | | - for (Field field : clazz.getDeclaredFields()) { |
1164 | | - if (isStaticField(field) && !isFinalField(field)) { |
1165 | | - String desc = Type.getDescriptor(field.getType()); |
1166 | | - FieldNode fieldNode = |
1167 | | - new FieldNode(field.getModifiers(), field.getName(), desc, null, field); |
1168 | | - results.add(fieldNode); |
1169 | | - LOGGER.debug("Adding static inherited field {}", fieldNode.name); |
1170 | | - fieldCount++; |
1171 | | - if (fieldCount > limits.maxFieldCount) { |
1172 | | - return; |
1173 | | - } |
1174 | | - } |
1175 | | - } |
1176 | | - } catch (ClassCircularityError ex) { |
1177 | | - break; |
1178 | | - } |
1179 | | - clazz = clazz.getSuperclass(); |
1180 | | - superClassName = clazz.getTypeName(); |
1181 | | - } |
1182 | | - } |
1183 | | - |
1184 | 1145 | private int declareContextVar(InsnList insnList) { |
1185 | 1146 | int var = newVar(CAPTURED_CONTEXT_TYPE); |
1186 | 1147 | getStatic(insnList, CAPTURED_CONTEXT_TYPE, "EMPTY_CAPTURING_CONTEXT"); |
|
0 commit comments