Browse Source

* pas2jni: Fixed exception handling.

git-svn-id: trunk@41396 -
yury 6 years ago
parent
commit
c0e1ec9121
1 changed files with 1 additions and 5 deletions
  1. 1 5
      utils/pas2jni/writer.pas

+ 1 - 5
utils/pas2jni/writer.pas

@@ -2192,8 +2192,6 @@ begin
   Fps.WriteLn('Result:=JNI_ERR;');
   Fps.WriteLn('Result:=JNI_ERR;');
   Fps.WriteLn('if vm^^.GetEnv(vm, @env, JNI_VERSION_1_6) <> JNI_OK then exit;');
   Fps.WriteLn('if vm^^.GetEnv(vm, @env, JNI_VERSION_1_6) <> JNI_OK then exit;');
   Fps.WriteLn('CurJavaVM:=vm;');
   Fps.WriteLn('CurJavaVM:=vm;');
-  Fps.WriteLn('_JavaExceptionClass:=env^^.FindClass(env, ''java/lang/Exception'');');
-  Fps.WriteLn('if _JavaExceptionClass = nil then exit;');
 
 
   d:=TTypeDef.Create(nil, dtType);
   d:=TTypeDef.Create(nil, dtType);
   try
   try
@@ -3006,8 +3004,6 @@ begin
     Fps.DecI;
     Fps.DecI;
     Fps.WriteLn('end;');
     Fps.WriteLn('end;');
 
 
-    Fps.WriteLn;
-    Fps.WriteLn('var _JavaExceptionClass: jclass;');
     Fps.WriteLn;
     Fps.WriteLn;
     Fps.WriteLn('procedure _HandleJNIException(env: PJNIEnv);');
     Fps.WriteLn('procedure _HandleJNIException(env: PJNIEnv);');
     Fps.WriteLn('begin');
     Fps.WriteLn('begin');
@@ -3016,7 +3012,7 @@ begin
       Fps.WriteLn(Format('%s.%s;', [p.OnExceptionProc.Parent.Name, p.OnExceptionProc.Name]), 1);
       Fps.WriteLn(Format('%s.%s;', [p.OnExceptionProc.Parent.Name, p.OnExceptionProc.Name]), 1);
       p.OnExceptionProc.SetNotUsed;
       p.OnExceptionProc.SetNotUsed;
     end;
     end;
-    Fps.WriteLn('env^^.ThrowNew(env, _JavaExceptionClass, PAnsiChar(Utf8Encode(Exception(ExceptObject).Message)));', 1);
+    Fps.WriteLn('env^^.ThrowNew(env, env^^.FindClass(env, ''java/lang/Exception''), PAnsiChar(Utf8Encode(Exception(ExceptObject).Message)));', 1);
     Fps.WriteLn('end;');
     Fps.WriteLn('end;');
 
 
     Fps.WriteLn;
     Fps.WriteLn;