Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Java.Interop.Dynamic] Use JniTypeSignature.Name for JniType.
While running the Java.Interop.Dynamic unit tests, the JDK was issuing a WARNING: $ make run-tests TESTS=bin/Debug/Java.Interop.Dynamic-Tests.dll ... WARNING in native method: JNI FindClass received a bad class descriptor "Ljava/lang/Integer;". A correct class descriptor has no leading "L" or trailing ";". Incorrect descriptors will not be accepted in future releases. The source of the warning was due to JavaClassInfo.GetJniTypes(), which was passing the result of JniTypeSignature.QualifiedReference to the JniType constructor: // WRONG var sig = JniRuntime.CurrentRuntime.TypeManager.GetTypeSignature (a.LimitType); var type = new JniType (sig.QualifiedReference); This is WRONG, because JniTypeSignature.QualifiedReference *always* provides the "full" type, e.g. `Ljava/lang/Integer;`. As per the JDK warning, this isn't correct. Instead, JavaClassInfo.GetJniTypes() should instead use JniTypeSignature.Name, e.g. `java/lang/Integer`, which provides the correct value for the JniType constructor: // RIGHT var sig = JniRuntime.CurrentRuntime.TypeManager.GetTypeSignature (a.LimitType); var type = new JniType (sig.Name); I wonder if this means there should be a JniTypeSignature.CreateType() method which creates the JniType instance... Fixing JavaClassInfo.GetJniTypes() removes the JDK warning. Further inspection of all uses of JniTypeSignature.QualifiedReference found JavaMethodBase.CompatibleWith(), which compares the result of JniEnvironment.Types.GetJniTypeNameFromClass() to JnITypeSignature.QualifiedReference, which doens't make sense as the former is really java.lang.Class.getName(), which is really JniTypeSignature.Name, not .QualifiedReference. Fix that.
- Loading branch information