Skip to content

[Java.Interop] Fix NRT warnings introduced by targeting 'net6.0'. #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Java.Interop.Export/Java.Interop/MarshalMemberBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public LambdaExpression CreateMarshalToManagedExpression (MethodInfo method, Jav
var marshalerContext = new JniValueMarshalerContext (jvm, useVmVariable ? vm : null);
if (!method.IsStatic) {
var selfMarshaler = Runtime.ValueManager.GetValueMarshaler (type);
self = selfMarshaler.CreateParameterToManagedExpression (marshalerContext, context, 0, type);
self = selfMarshaler.CreateParameterToManagedExpression (marshalerContext, context, type, 0);
}

var marshalParameters = new List<ParameterExpression> (methodParameters.Length);
Expand All @@ -176,7 +176,7 @@ public LambdaExpression CreateMarshalToManagedExpression (MethodInfo method, Jav
else
throw new InvalidOperationException ("Should not be reached.");
}
var p = marshaler.CreateParameterToManagedExpression (marshalerContext, np, methodParameters [i].Attributes, methodParameters [i].ParameterType);
var p = marshaler.CreateParameterToManagedExpression (marshalerContext, np, methodParameters [i].ParameterType, methodParameters [i].Attributes);
marshalParameters.Add (np);
invokeParameters.Add (p);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Java.Interop/Java.Interop/JavaPrimitiveArrays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Boolean> val
JavaArray<Boolean>.DestroyArgumentState<JavaBooleanArray> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaBooleanArray.CreateMarshaledValue;

Expand Down Expand Up @@ -439,7 +439,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<SByte> value
JavaArray<SByte>.DestroyArgumentState<JavaSByteArray> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaSByteArray.CreateMarshaledValue;

Expand Down Expand Up @@ -615,7 +615,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Char> value,
JavaArray<Char>.DestroyArgumentState<JavaCharArray> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaCharArray.CreateMarshaledValue;

Expand Down Expand Up @@ -791,7 +791,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Int16> value
JavaArray<Int16>.DestroyArgumentState<JavaInt16Array> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaInt16Array.CreateMarshaledValue;

Expand Down Expand Up @@ -967,7 +967,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Int32> value
JavaArray<Int32>.DestroyArgumentState<JavaInt32Array> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaInt32Array.CreateMarshaledValue;

Expand Down Expand Up @@ -1143,7 +1143,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Int64> value
JavaArray<Int64>.DestroyArgumentState<JavaInt64Array> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaInt64Array.CreateMarshaledValue;

Expand Down Expand Up @@ -1319,7 +1319,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Single> valu
JavaArray<Single>.DestroyArgumentState<JavaSingleArray> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaSingleArray.CreateMarshaledValue;

Expand Down Expand Up @@ -1495,7 +1495,7 @@ public override void DestroyGenericArgumentState ([AllowNull] IList<Double> valu
JavaArray<Double>.DestroyArgumentState<JavaDoubleArray> (value, ref state, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType = null, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type?, object?> m = JavaDoubleArray.CreateMarshaledValue;

Expand Down
16 changes: 8 additions & 8 deletions src/Java.Interop/Java.Interop/JniBuiltinMarshalers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public override void DestroyGenericArgumentState (Boolean value, ref JniValueMar
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -386,7 +386,7 @@ public override void DestroyGenericArgumentState (SByte value, ref JniValueMarsh
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -513,7 +513,7 @@ public override void DestroyGenericArgumentState (Char value, ref JniValueMarsha
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -640,7 +640,7 @@ public override void DestroyGenericArgumentState (Int16 value, ref JniValueMarsh
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -767,7 +767,7 @@ public override void DestroyGenericArgumentState (Int32 value, ref JniValueMarsh
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -894,7 +894,7 @@ public override void DestroyGenericArgumentState (Int64 value, ref JniValueMarsh
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -1021,7 +1021,7 @@ public override void DestroyGenericArgumentState (Single value, ref JniValueMars
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down Expand Up @@ -1148,7 +1148,7 @@ public override void DestroyGenericArgumentState (Double value, ref JniValueMars
state = new JniValueMarshalerState ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public override Expression CreateParameterFromManagedExpression (Java.Interop.Ex
return sourceValue;
}

public override Expression CreateParameterToManagedExpression (Java.Interop.Expressions.JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (Java.Interop.Expressions.JniValueMarshalerContext context, ParameterExpression sourceValue, Type? targetType, ParameterAttributes synchronize)
{
return sourceValue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniRuntime.JniTypeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected virtual IEnumerable<string> GetSimpleReferences (Type type)
static readonly Type[] EmptyTypeArray = Array.Empty<Type> ();


public Type GetType (JniTypeSignature typeSignature)
public Type? GetType (JniTypeSignature typeSignature)
{
AssertValid ();

Expand Down
8 changes: 4 additions & 4 deletions src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ static Type GetPeerType (Type type)
return GetActivationConstructor (fallbackType);
}

static ConstructorInfo GetActivationConstructor (Type type)
static ConstructorInfo? GetActivationConstructor (Type type)
{
return
(from c in type.GetConstructors (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
Expand Down Expand Up @@ -673,7 +673,7 @@ public override Expression CreateReturnValueFromManagedExpression (JniValueMarsh
return ReturnObjectReferenceToJni (context, sourceValue.Name, CreateIntermediaryExpressionFromManagedExpression (context, sourceValue));
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize)
{
var r = Expression.Variable (targetType, sourceValue.Name + "_val");
context.LocalVariables.Add (r);
Expand Down Expand Up @@ -718,9 +718,9 @@ public override Expression CreateParameterFromManagedExpression (JniValueMarshal
return ValueMarshaler.CreateParameterFromManagedExpression (context, sourceValue, synchronize);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize)
{
return ValueMarshaler.CreateParameterToManagedExpression (context, sourceValue, synchronize, targetType);
return ValueMarshaler.CreateParameterToManagedExpression (context, sourceValue, targetType, synchronize);
}

public override Expression CreateReturnValueFromManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue)
Expand Down
2 changes: 1 addition & 1 deletion src/Java.Interop/Java.Interop/JniStringValueMarshaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public override Expression CreateReturnValueFromManagedExpression (JniValueMarsh
return ReturnObjectReferenceToJni (context, sourceValue.Name, obj);
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type? targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize)
{
Func<IntPtr, string?> m = JniEnvironment.Strings.ToString;

Expand Down
6 changes: 3 additions & 3 deletions src/Java.Interop/Java.Interop/JniValueMarshaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sealed class VariableCollection : KeyedCollection<string, ParameterExpression> {

protected override string GetKeyForItem (ParameterExpression item)
{
return item.Name;
return item.Name!;
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ public virtual JniValueMarshalerState CreateArgumentState (object? value,
return CreateValue (ref r, JniObjectReferenceOptions.Copy, targetType);
}

public virtual Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize = 0, Type? targetType = null)
public virtual Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize = 0)
{
Func<IntPtr, Type, object?> m = CreateValue;

Expand All @@ -169,7 +169,7 @@ public virtual Expression CreateReturnValueFromManagedExpressi
return ReturnObjectReferenceToJni (context, sourceValue.Name, Expression.Property (s, "ReferenceValue"));
}

protected Expression ReturnObjectReferenceToJni (JniValueMarshalerContext context, string namePrefix, Expression sourceValue)
protected Expression ReturnObjectReferenceToJni (JniValueMarshalerContext context, string? namePrefix, Expression sourceValue)
{
Func<JniObjectReference, IntPtr> m = JniEnvironment.References.NewReturnToJniRef;
var r = Expression.Variable (MarshalType, namePrefix + "_rtn");
Expand Down
4 changes: 2 additions & 2 deletions tests/Java.Interop.Export-Tests/Java.Interop/ExportTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public override void DestroyGenericArgumentState (MyColor value, ref JniValueMar
throw new NotImplementedException ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize)
{
var c = typeof (MyColor).GetConstructor (new[]{typeof (int)});
var v = Expression.Variable (typeof (MyColor), sourceValue.Name + "_val");
Expand Down Expand Up @@ -253,7 +253,7 @@ public override void DestroyGenericArgumentState (MyLegacyColor value, ref JniVa
throw new NotImplementedException ();
}

public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, ParameterAttributes synchronize, Type targetType)
public override Expression CreateParameterToManagedExpression (JniValueMarshalerContext context, ParameterExpression sourceValue, Type targetType, ParameterAttributes synchronize)
{
var c = typeof (MyLegacyColor).GetConstructor (new[]{typeof (int)});
var v = Expression.Variable (typeof (MyLegacyColor), sourceValue.Name + "_val");
Expand Down