mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 02:50:42 +02:00
* catch JLRInvocationTargetException raised when using JLRMthod.invoke() to
call a procvar (includes virtual constructors and virtual class methods), and raise its getCause() so that the original exception is propagated to the caller git-svn-id: branches/jvmbackend@19030 -
This commit is contained in:
parent
019a58ab1d
commit
fdab7122dd
@ -2139,6 +2139,16 @@
|
||||
constructor create(para1: JLThrowable); overload;
|
||||
end;
|
||||
|
||||
JLRInvocationTargetException = class external 'java.lang.reflect' name 'InvocationTargetException' (JLException)
|
||||
strict protected
|
||||
constructor create(); overload;
|
||||
public
|
||||
constructor create(para1: JLThrowable); overload;
|
||||
constructor create(para1: JLThrowable; para2: JLString); overload;
|
||||
function getTargetException(): JLThrowable; overload; virtual;
|
||||
function getCause(): JLThrowable; overload; virtual;
|
||||
end;
|
||||
|
||||
JLStringBuffer = class sealed external 'java.lang' name 'StringBuffer' (JLAbstractStringBuilder, JISerializable, JLCharSequence)
|
||||
public
|
||||
constructor create(); overload;
|
||||
|
@ -30,6 +30,11 @@ type
|
||||
Arr2JLRField = array of Arr1JLRField;
|
||||
Arr3JLRField = array of Arr2JLRField;
|
||||
|
||||
JLRInvocationTargetException = class;
|
||||
Arr1JLRInvocationTargetException = array of JLRInvocationTargetException;
|
||||
Arr2JLRInvocationTargetException = array of Arr1JLRInvocationTargetException;
|
||||
Arr3JLRInvocationTargetException = array of Arr2JLRInvocationTargetException;
|
||||
|
||||
JNBuffer = class;
|
||||
Arr1JNBuffer = array of JNBuffer;
|
||||
Arr2JNBuffer = array of Arr1JNBuffer;
|
||||
|
@ -15913,16 +15913,6 @@
|
||||
constructor create(para1: JLString); overload;
|
||||
end;
|
||||
|
||||
JLRInvocationTargetException = class external 'java.lang.reflect' name 'InvocationTargetException' (JLException)
|
||||
strict protected
|
||||
constructor create(); overload;
|
||||
public
|
||||
constructor create(para1: JLThrowable); overload;
|
||||
constructor create(para1: JLThrowable; para2: JLString); overload;
|
||||
function getTargetException(): JLThrowable; overload; virtual;
|
||||
function getCause(): JLThrowable; overload; virtual;
|
||||
end;
|
||||
|
||||
JNURISyntaxException = class external 'java.net' name 'URISyntaxException' (JLException)
|
||||
public
|
||||
constructor create(para1: JLString; para2: JLString; para3: jint); overload;
|
||||
|
@ -14440,11 +14440,6 @@ type
|
||||
Arr2JSRSSQLInputImpl = array of Arr1JSRSSQLInputImpl;
|
||||
Arr3JSRSSQLInputImpl = array of Arr2JSRSSQLInputImpl;
|
||||
|
||||
JLRInvocationTargetException = class;
|
||||
Arr1JLRInvocationTargetException = array of JLRInvocationTargetException;
|
||||
Arr2JLRInvocationTargetException = array of Arr1JLRInvocationTargetException;
|
||||
Arr3JLRInvocationTargetException = array of Arr2JLRInvocationTargetException;
|
||||
|
||||
OXSSAXParseException = class;
|
||||
Arr1OXSSAXParseException = array of OXSSAXParseException;
|
||||
Arr2OXSSAXParseException = array of Arr1OXSSAXParseException;
|
||||
|
@ -100,91 +100,141 @@
|
||||
in a synchronised way. Doing it at construction time and in fpcDeepCopy/
|
||||
clone is not enough, because the method field can be manipulated
|
||||
directly }
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
method.code.invoke(method.data,args)
|
||||
else
|
||||
method.code.invoke(method.data,getClassProcArgs(args));
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
method.code.invoke(method.data,args)
|
||||
else
|
||||
method.code.invoke(method.data,getClassProcArgs(args));
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeBooleanFunc(const args: array of jlobject): jboolean;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLBoolean(method.code.invoke(method.data,args)).booleanValue
|
||||
else
|
||||
result:=JLBoolean(method.code.invoke(method.data,getClassProcArgs(args))).booleanValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLBoolean(method.code.invoke(method.data,args)).booleanValue
|
||||
else
|
||||
result:=JLBoolean(method.code.invoke(method.data,getClassProcArgs(args))).booleanValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeCharFunc(const args: array of jlobject): jchar;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLCharacter(method.code.invoke(method.data,args)).charValue
|
||||
else
|
||||
result:=JLCharacter(method.code.invoke(method.data,getClassProcArgs(args))).charValue;
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLCharacter(method.code.invoke(method.data,args)).charValue
|
||||
else
|
||||
result:=JLCharacter(method.code.invoke(method.data,getClassProcArgs(args))).charValue;
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeByteFunc(const args: array of jlobject): jbyte;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLByte(method.code.invoke(method.data,args)).byteValue
|
||||
else
|
||||
result:=JLByte(method.code.invoke(method.data,getClassProcArgs(args))).byteValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLByte(method.code.invoke(method.data,args)).byteValue
|
||||
else
|
||||
result:=JLByte(method.code.invoke(method.data,getClassProcArgs(args))).byteValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeShortFunc(const args: array of jlobject): jshort;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLShort(method.code.invoke(method.data,args)).shortValue
|
||||
else
|
||||
result:=JLShort(method.code.invoke(method.data,getClassProcArgs(args))).shortValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLShort(method.code.invoke(method.data,args)).shortValue
|
||||
else
|
||||
result:=JLShort(method.code.invoke(method.data,getClassProcArgs(args))).shortValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeIntFunc(const args: array of jlobject): jint;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLInteger(method.code.invoke(method.data,args)).intValue
|
||||
else
|
||||
result:=JLInteger(method.code.invoke(method.data,getClassProcArgs(args))).intValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLInteger(method.code.invoke(method.data,args)).intValue
|
||||
else
|
||||
result:=JLInteger(method.code.invoke(method.data,getClassProcArgs(args))).intValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeLongFunc(const args: array of jlobject): jlong;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLLong(method.code.invoke(method.data,args)).longValue
|
||||
else
|
||||
result:=JLLong(method.code.invoke(method.data,getClassProcArgs(args))).longValue;
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLLong(method.code.invoke(method.data,args)).longValue
|
||||
else
|
||||
result:=JLLong(method.code.invoke(method.data,getClassProcArgs(args))).longValue;
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeSingleFunc(const args: array of jlobject): jfloat;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLFloat(method.code.invoke(method.data,args)).floatValue
|
||||
else
|
||||
result:=JLFloat(method.code.invoke(method.data,getClassProcArgs(args))).floatValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLFloat(method.code.invoke(method.data,args)).floatValue
|
||||
else
|
||||
result:=JLFloat(method.code.invoke(method.data,getClassProcArgs(args))).floatValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeDoubleFunc(const args: array of jlobject): jdouble;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLDouble(method.code.invoke(method.data,args)).doubleValue
|
||||
else
|
||||
result:=JLDouble(method.code.invoke(method.data,getClassProcArgs(args))).doubleValue
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=JLDouble(method.code.invoke(method.data,args)).doubleValue
|
||||
else
|
||||
result:=JLDouble(method.code.invoke(method.data,getClassProcArgs(args))).doubleValue
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
function FpcBaseProcVarType.invokeObjectFunc(const args: array of jlobject): jlobject;
|
||||
begin
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=method.code.invoke(method.data,args)
|
||||
else
|
||||
result:=method.code.invoke(method.data,getClassProcArgs(args))
|
||||
try
|
||||
if length(method.code.getParameterTypes)=length(args) then
|
||||
result:=method.code.invoke(method.data,args)
|
||||
else
|
||||
result:=method.code.invoke(method.data,getClassProcArgs(args))
|
||||
except
|
||||
on e: JLRInvocationTargetException do
|
||||
raise e.getCause
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user