Juliano
Juliano

Reputation: 153

Binding Jar Library

I'm trying to bind a jar library (jCIFS) on MFA, but i'm stuck on some errors, like this one:

'Jcifs.Util.MD4' does not implement inherited abstract member 'Java.Security.MessageDigestSpi.EngineDigest()

After some research, i found some topics about this, telling to edit the metadata to change the permissions of the classes, like this:

<attr path="/api/package[@name='java.security']/class[@name='MessageDigestSpi']/method[@name='engineDigest']" name="visibility">public</attr>

But the error didn't change, and a still won't get what this error means.

Anyone ?

Edit: This's the code of virtual class who return me the error:

    public virtual byte[] EngineDigest ()
    {
        if (id_engineDigest == IntPtr.Zero)
            id_engineDigest = JNIEnv.GetMethodID (class_ref, "engineDigest", "()[B");

        if (GetType () == ThresholdType)
            return (byte[]) JNIEnv.GetArray (JNIEnv.CallObjectMethod  (Handle, id_engineDigest), JniHandleOwnership.TransferLocalRef, typeof (byte));
        else
            return (byte[]) JNIEnv.GetArray (JNIEnv.CallNonvirtualObjectMethod  (Handle, ThresholdClass, id_engineDigest), JniHandleOwnership.TransferLocalRef, typeof (byte));
    }

And i added this in a new file:

partial class MD4
{
    public override byte[] EngineDigest()
    {
        return null;
    }
}

If i do that, this error is returned:

Error 1 Type 'Jcifs.Util.MD4' already defines a member called 'EngineDigest' with the same parameter types

From what I understand, the method EngineDigest already exists, but the class needs to implement it. How i do that ?

The full error: Error 195 'Jcifs.Util.MD4' does not implement inherited abstract member 'Java.Security.MessageDigestSpi.EngineDigest()'

Edit 2: I've tried to reply the problem using OsmDroidBinding example from xamarin site. I edited the metafile until i get a similar error. And one of the lines i found was this one:

<attr path="/api/package[@name='org.osmdroid.tileprovider']/class[@name='MapTileProviderBase.ScaleTileLooper']/method[@name='handleTile']" name="visibility">public</attr>

And i get this error: Error

Then i tried to add this to my project metafile (like above), but the error persists:

<attr path="/api/package[@name='java.security']/class[@name='MessageDigestSpi']/method[@name='engineDigest']" name="visibility">public</attr>

Thanks.

Upvotes: 2

Views: 1538

Answers (2)

Soufiene
Soufiene

Reputation: 2218

Change

public override byte[] EngineDigest ()

To

protected override byte[] EngineDigest ()

Upvotes: 0

Alex Wiese
Alex Wiese

Reputation: 8370

It is telling you that the generated class Jcifs.Util.MD4 doesn't implement an inherited abstract method. An abstract method is a method which must be overridden by any derived class.

The code below is changing the visibility of the base class's method to public, which obviously won't fix the problem.

<attr path="/api/package[@name='java.security']/class[@name='MessageDigestSpi']/method[@name='engineDigest']" name="visibility">public</attr>

There are several ways you could fix this error. Perhaps the easiest would be to add a class file to your Java Binding Library and add the following code to it.

namespace Jcifs.Util
{
    public partial class MD4
    {
        public override void EngineDigest()
        {

        }
    }
}

NOTE You will need to change the return type of EngineDigest() to the return type defined for the abstract method in the base class. You haven't mentioned the return type in your question so I made it void.

Upvotes: 2

Related Questions