Skip to content

Commit 34775a4

Browse files
committed
surprisingly, not compiling the code doesn't guarantee it's right.
1 parent 8bd936b commit 34775a4

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/vm/jvm/runtime/org/perl6/nqp/runtime/BootJavaInterop.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private static class InteropInfo {
7676

7777
private int getInheritanceDepth(Class<?> klass) {
7878
if (klass.getName().equals("java.lang.Object")) {
79-
return 1
79+
return 1;
8080
} else {
8181
return 1 + getInheritanceDepth(klass.getSuperclass());
8282
}
@@ -333,7 +333,7 @@ protected ClassContext createAdaptor(Class<?> target) {
333333
cc.className = className;
334334
cc.target = target;
335335

336-
for (method m : target.getMethods()) analyzeMethodHiding(cc, m);
336+
for (Method m : target.getMethods()) analyzeMethodHiding(cc, m);
337337

338338
for (Method m : target.getMethods()) createAdaptorMethod(cc, m);
339339
for (Field f : target.getFields()) createAdaptorField(cc, f);
@@ -347,22 +347,22 @@ protected ClassContext createAdaptor(Class<?> target) {
347347
}
348348

349349
protected void analyzeMethodHiding(ClassContext cc, Method m) {
350-
String desc = type.getMethodDescriptor(m);
350+
String desc = Type.getMethodDescriptor(m);
351351

352352
int s2 = desc.indexOf(')');
353353
String fragment = desc.substring(s2);
354354

355-
Integer derivationDepth = getInheritanceDepth(m);
355+
Integer derivationDepth = getInheritanceDepth(m.getDeclaringClass());
356356

357357
if (cc.inheritanceHiding.containsKey(fragment)) {
358-
ClassContext.HidingInformation info = cc.inheritanceHiding.get(fragment);
358+
HidingInformation info = cc.inheritanceHiding.get(fragment);
359359

360360
if (derivationDepth > info.inheritanceDepth) {
361361
info.inheritanceDepth = derivationDepth;
362362
info.mostSpecificSignature = desc;
363363
}
364364
} else {
365-
ClassContext.HidingInformation info = new ClassContext.HidingInformation;
365+
HidingInformation info = new HidingInformation();
366366

367367
info.inheritanceDepth = derivationDepth;
368368
info.mostSpecificSignature = desc;
@@ -538,6 +538,7 @@ protected void createAdaptorMethod(ClassContext c, Method tobind) {
538538
boolean isStatic = Modifier.isStatic(tobind.getModifiers());
539539

540540
String desc = Type.getMethodDescriptor(tobind);
541+
String name = tobind.getName();
541542
Integer arity = ptype.length;
542543

543544
int returnPos = desc.indexOf(')');
@@ -859,14 +860,15 @@ else if (what == ThreadContext.class) {
859860
/** Type name of {@link ThreadContext}. */
860861
protected static final Type TYPE_TC = Type.getType(ThreadContext.class);
861862

863+
/** Store information needed to figure out which methods are hidden */
864+
protected class HidingInformation {
865+
/** How far away from java.lang.object are we? */
866+
public Integer inheritanceDepth;
867+
/** Which signature has been the most derived version so far? */
868+
public String mostSpecificSignature;
869+
}
862870
/** Stores working information while building a class. */
863871
protected static class ClassContext {
864-
protected class HidingInformation {
865-
/** How far away from java.lang.object are we? */
866-
public Integer inheritanceDepth;
867-
/** Which signature has been the most derived version so far? */
868-
public String mostSpecificSignature;
869-
}
870872
/** The ASM class writer. */
871873
public ClassWriter cv;
872874
/** The new class' internal name. */

0 commit comments

Comments
 (0)