Język

JavaPeerProxy Class

Definition

Base attribute class for generated proxy types that enable AOT-safe type mapping between Java and .NET types.

[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=false, Inherited=false)]
public abstract class JavaPeerProxy : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=false, Inherited=false)>]
type JavaPeerProxy = class
    inherit Attribute
Inheritance
JavaPeerProxy
Attributes

Remarks

Proxy attributes are generated at build time and applied to the proxy type itself (self-application pattern). The .NET runtime's GetCustomAttribute<JavaPeerProxy>() instantiates the proxy in an AOT-safe manner — no Activator.CreateInstance() needed.

Constructors

Name Description
JavaPeerProxy(String, Type)

Properties

Name Description
JniName

Gets the final JNI type name of the Java class this proxy represents.

TargetType

Gets the target .NET type that this proxy represents.

Methods

Name Description
CreateInstance(IntPtr, JniHandleOwnership)

Creates an instance of the target type using the JNI handle and ownership semantics. This replaces the reflection-based constructor invocation used in the legacy path.

GetActivationPeer(IntPtr)
MarkActivationPeerReplaceable(IntPtr)
SetActivationPeerReference(IJavaPeerable, IntPtr)
ShouldSkipActivation(IntPtr)

Returns true when the UCO constructor callback should skip activation because a managed peer already exists for the given JNI handle (e.g., when called from FinishCreateInstance after StartCreateInstance already registered the peer).

Applies to