C # attribute goals - How to port code with target objects in Java?

First of all, we are talking about Keepass here.
This file: KeePass-2.19-Source\KeePass\Native\NativeMethods.cs

The code ... well, this is the file itself. But here is a snippet:

  [DllImport("KeePassLibC32.dll", EntryPoint = "TransformKey256")] [return: MarshalAs(UnmanagedType.Bool)] private static extern bool TransformKey32(IntPtr pBuf256, IntPtr pKey256, UInt64 uRounds); 

Now the problem is that Java does not support Target Targets . How to transfer a file to Java? Is it possible? If so ... how?

+4
source share
2 answers

Java does support target attribute attributes (but they are "annotation" objects): http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/annotation/Target.html

But that won’t help you ... unless you plan to invent your own DllImport that somehow uses JNI ... something like JSR-299

0
source

As far as I know, Java does not support P / Invoke, so attribute goals will not help you ... You should be able to achieve the same result with JNI, but this code cannot be translated literally from C #.

0
source

All Articles