Skip to content

Commit

Permalink
No methodHandle#invokeWithArguments for procedures
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusmelke committed Feb 28, 2018
1 parent 2f50d43 commit 00fcace
Showing 1 changed file with 16 additions and 12 deletions.
Expand Up @@ -240,8 +240,6 @@ private CallableProcedure compileProcedure( Class<?> procDefinition, MethodHandl
Optional<String> warning, boolean fullAccess, QualifiedName procName )
throws ProcedureException, IllegalAccessException
{
MethodHandle procedureMethod = lookup.unreflect( method );

List<FieldSignature> inputSignature = inputSignatureDeterminer.signatureFor( method );
OutputMapper outputMapper = outputMappers.mapper( method );

Expand Down Expand Up @@ -284,7 +282,7 @@ private CallableProcedure compileProcedure( Class<?> procDefinition, MethodHandl
ProcedureSignature signature =
new ProcedureSignature( procName, inputSignature, outputMapper.signature(), mode, deprecated,
config.rolesFor( procName.toString() ), description, warning );
return new ReflectiveProcedure( signature, constructor, procedureMethod, outputMapper, setters );
return new ReflectiveProcedure( signature, constructor, method, outputMapper, setters );
}

private Optional<String> describeAndLogLoadFailure( QualifiedName name )
Expand Down Expand Up @@ -555,10 +553,10 @@ private static class ReflectiveProcedure extends ReflectiveBase implements Calla
private final ProcedureSignature signature;
private final OutputMapper outputMapper;
private final MethodHandle constructor;
private final MethodHandle procedureMethod;
private final Method procedureMethod;

ReflectiveProcedure( ProcedureSignature signature, MethodHandle constructor,
MethodHandle procedureMethod, OutputMapper outputMapper,
Method procedureMethod, OutputMapper outputMapper,
List<FieldInjections.FieldSetter> fieldSetters )
{
super( fieldSetters );
Expand Down Expand Up @@ -596,9 +594,7 @@ public RawIterator<Object[],ProcedureException> apply( Context ctx, Object[] inp
inject( ctx, cls );

// Call the method
Object[] args = args( numberOfDeclaredArguments, cls, input );

Object rs = procedureMethod.invokeWithArguments( args );
Object rs = procedureMethod.invoke( cls, input );

// This also handles VOID
if ( rs == null )
Expand Down Expand Up @@ -702,10 +698,18 @@ private ProcedureException closeAndCreateProcedureException( Throwable t )

private ProcedureException newProcedureException( Throwable throwable )
{
return throwable instanceof Status.HasStatus ?
new ProcedureException( ((Status.HasStatus) throwable).status(), throwable, throwable.getMessage() ) :
new ProcedureException( Status.Procedure.ProcedureCallFailed, throwable,
"Failed to invoke procedure `%s`: %s", signature.name(), "Caused by: " + throwable );
if (throwable instanceof Status.HasStatus )
{
return new ProcedureException( ((Status.HasStatus) throwable).status(), throwable, throwable.getMessage() );
}
else
{
Throwable cause = ExceptionUtils.getRootCause( throwable );
return new ProcedureException( Status.Procedure.ProcedureCallFailed, throwable,
"Failed to invoke procedure `%s`: %s", signature.name(),
"Caused by: " + (cause != null ? cause : throwable) );
}

}
}

Expand Down

0 comments on commit 00fcace

Please sign in to comment.