diff options
author | jfrijters <jfrijters> | 2015-06-29 12:56:13 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2015-06-29 12:56:13 +0300 |
commit | c3fea8fff4c387329567a28881b0b074e3496fb7 (patch) | |
tree | 7c4bd1eb99b033676311269a8a6710ae3a41c71d | |
parent | 31737736c53e39e2f1139b92ed5479092ffc0b59 (diff) |
Added MethodWrapper.IsClassInitializer and use it and IsConstructor instead of name comparisons.
-rw-r--r-- | runtime/MemberWrapper.cs | 5 | ||||
-rw-r--r-- | runtime/intrinsics.cs | 2 | ||||
-rw-r--r-- | runtime/openjdk/java.lang.cs | 7 | ||||
-rw-r--r-- | runtime/openjdk/java.lang.invoke.cs | 2 | ||||
-rw-r--r-- | runtime/stubgen/SerialVersionUID.cs | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/runtime/MemberWrapper.cs b/runtime/MemberWrapper.cs index 27e4bdc8..0778e0d4 100644 --- a/runtime/MemberWrapper.cs +++ b/runtime/MemberWrapper.cs @@ -853,6 +853,11 @@ namespace IKVM.Internal get { return (object)Name == (object)StringConstants.INIT; } } + internal bool IsClassInitializer + { + get { return (object)Name == (object)StringConstants.CLINIT; } + } + internal bool IsVirtual { get diff --git a/runtime/intrinsics.cs b/runtime/intrinsics.cs index f058c4c9..c8ed3701 100644 --- a/runtime/intrinsics.cs +++ b/runtime/intrinsics.cs @@ -616,7 +616,7 @@ namespace IKVM.Internal { // it is only valid to replace a ThreadLocal instantiation by our ThreadStatic based version, if we can prove that the instantiation only happens once // (which is the case when we're in <clinit> and there aren't any branches that lead to the current position) - if (eic.Caller.Name != StringConstants.CLINIT) + if (!eic.Caller.IsClassInitializer) { return false; } diff --git a/runtime/openjdk/java.lang.cs b/runtime/openjdk/java.lang.cs index 95bd78f9..838689dd 100644 --- a/runtime/openjdk/java.lang.cs +++ b/runtime/openjdk/java.lang.cs @@ -543,13 +543,14 @@ static class Java_java_lang_Class throw new ClassFormatError(wrapper.Name); } MethodWrapper[] methods = wrapper.GetMethods(); - List<java.lang.reflect.Method> list = new List<java.lang.reflect.Method>(); + List<java.lang.reflect.Method> list = new List<java.lang.reflect.Method>(methods.Length); for (int i = 0; i < methods.Length; i++) { // we don't want to expose "hideFromReflection" methods (one reason is that it would // mess up the serialVersionUID computation) if (!methods[i].IsHideFromReflection - && methods[i].Name != "<clinit>" && methods[i].Name != "<init>" + && !methods[i].IsConstructor + && !methods[i].IsClassInitializer && (!publicOnly || methods[i].IsPublic)) { list.Add((java.lang.reflect.Method)methods[i].ToMethodOrConstructor(false)); @@ -595,7 +596,7 @@ static class Java_java_lang_Class // we don't want to expose "hideFromReflection" methods (one reason is that it would // mess up the serialVersionUID computation) if (!methods[i].IsHideFromReflection - && methods[i].Name == "<init>" + && methods[i].IsConstructor && (!publicOnly || methods[i].IsPublic)) { list.Add((java.lang.reflect.Constructor)methods[i].ToMethodOrConstructor(false)); diff --git a/runtime/openjdk/java.lang.invoke.cs b/runtime/openjdk/java.lang.invoke.cs index bf04b4be..2f6a3187 100644 --- a/runtime/openjdk/java.lang.invoke.cs +++ b/runtime/openjdk/java.lang.invoke.cs @@ -507,7 +507,7 @@ static class Java_java_lang_invoke_MethodHandleNatives MethodWrapper[] methods = TypeWrapper.FromClass(defc).GetMethods(); for (int i = skip, len = Math.Min(results.Length, methods.Length - skip); i < len; i++) { - if (!methods[i].IsConstructor && methods[i].Name != StringConstants.CLINIT) + if (!methods[i].IsConstructor && !methods[i].IsClassInitializer) { results[i - skip] = new MemberName((java.lang.reflect.Method)methods[i].ToMethodOrConstructor(true), false); } diff --git a/runtime/stubgen/SerialVersionUID.cs b/runtime/stubgen/SerialVersionUID.cs index c445030f..e1555056 100644 --- a/runtime/stubgen/SerialVersionUID.cs +++ b/runtime/stubgen/SerialVersionUID.cs @@ -81,7 +81,7 @@ namespace IKVM.StubGen { foreach (MethodWrapper mw in tw.GetMethods()) { - if (!mw.IsHideFromReflection && mw.Name != StringConstants.CLINIT) + if (!mw.IsHideFromReflection && !mw.IsClassInitializer) { return true; } |