MCPcopy Create free account
hub / github.com/GregTech6/gregtech6 / getCommonSuperClass

Method getCommonSuperClass

src/main/java/gregtech/asm/GT_ASM.java:235–260  ·  view source on GitHub ↗
(String type1, String type2)

Source from the content-addressed store, hash-verified

233 // Forge's classloader doesn't seem to like loading and transforming a type while transforming another...
234 // Which wouldn't be an issue if things were loaded in the right order by forge's classloader, but meh...
235 @Override
236 protected String getCommonSuperClass(String type1, String type2) {
237 Class<?> c, d;
238 try {
239 c = Class.forName(type1.replace('/', '.'), false, GT_ASM.classLoader);
240 d = Class.forName(type2.replace('/', '.'), false, GT_ASM.classLoader);
241 } catch (Exception e) {
242 // We can't really unify this at this point because it's not loaded yet,
243 // but for this class its fine to return `"java/lang/Object"` for anything that is not loadable.
244 //throw new RuntimeException(e.toString());
245 return "java/lang/Object";
246 }
247 if (c.isAssignableFrom(d)) {
248 return type1;
249 }
250 if (d.isAssignableFrom(c)) {
251 return type2;
252 }
253 if (c.isInterface() || d.isInterface()) {
254 return "java/lang/Object";
255 }
256 do {
257 c = c.getSuperclass();
258 } while (!c.isAssignableFrom(d));
259 return c.getName().replace('.', '/');
260 }
261 };
262 aClassNode.accept(writer);
263 return writer.toByteArray();

Callers

nothing calls this directly

Calls 2

replaceMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected