diff --git a/src/avian/machine.h b/src/avian/machine.h index a53d4c98f2..ae6a0368da 100644 --- a/src/avian/machine.h +++ b/src/avian/machine.h @@ -1592,6 +1592,9 @@ class Classpath { canTailCall(Thread* t, object caller, object calleeClassName, object calleeMethodName, object calleeMethodSpec) = 0; + virtual void + shutDown(Thread* t) = 0; + virtual void dispose() = 0; }; diff --git a/src/classpath-android.cpp b/src/classpath-android.cpp index bc325470b4..87fa114cf0 100644 --- a/src/classpath-android.cpp +++ b/src/classpath-android.cpp @@ -469,6 +469,12 @@ class MyClasspath : public Classpath { return true; } + virtual void + shutDown(Thread*) + { + // ignore + } + virtual void dispose() { diff --git a/src/classpath-avian.cpp b/src/classpath-avian.cpp index 64c56fc389..ef16a767c1 100644 --- a/src/classpath-avian.cpp +++ b/src/classpath-avian.cpp @@ -186,6 +186,12 @@ class MyClasspath : public Classpath { return true; } + virtual void + shutDown(Thread*) + { + // ignore + } + virtual void dispose() { diff --git a/src/classpath-openjdk.cpp b/src/classpath-openjdk.cpp index c85c8a184c..1a70816295 100644 --- a/src/classpath-openjdk.cpp +++ b/src/classpath-openjdk.cpp @@ -897,6 +897,21 @@ class MyClasspath : public Classpath { (&byteArrayBody(t, calleeClassName, 0)))); } + virtual void + shutDown(Thread* t) + { + object c = resolveClass + (t, root(t, Machine::BootLoader), "java/lang/Shutdown", false); + + if (c) { + object m = findMethodOrNull(t, c, "shutdown", "()V"); + + if (m) { + t->m->processor->invoke(t, m, 0); + } + } + } + virtual void dispose() { diff --git a/src/machine.cpp b/src/machine.cpp index 3f66a3785c..4e6ccd8ce0 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2315,7 +2315,7 @@ parseAttributeTable(Thread* t, Stream& s, object class_, object pool) (&byteArrayBody(t, className(t, class_), 0), &byteArrayBody(t, innerClassReferenceInner(t, reference), 0))) { - classFlags(t, class_) |= flags; + classFlags(t, class_) = flags; } } @@ -3321,6 +3321,8 @@ shutDown(Thread* t) setRoot(t, Machine::ShutdownHooks, 0); + t->m->classpath->shutDown(t); + object h = hooks; PROTECT(t, h); for (; h; h = pairSecond(t, h)) { diff --git a/test/Misc.java b/test/Misc.java index 66f290f177..91195d5f13 100644 --- a/test/Misc.java +++ b/test/Misc.java @@ -259,5 +259,10 @@ public class Misc { expect((Baz.class.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0); + + expect((Protected.class.getModifiers() & java.lang.reflect.Modifier.PUBLIC) + == 0); } + + protected class Protected { } }