Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
4033d832
Commit
4033d832
authored
Jul 11, 2011
by
Andrey Pavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
native exception handling added
parent
d2270797
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
gen_java.py
modules/java/gen_java.py
+17
-0
CvException.java
modules/java/src/java/CvException.java
+15
-0
No files found.
modules/java/gen_java.py
View file @
4033d832
...
...
@@ -503,11 +503,14 @@ class JavaWrapperGenerator(object):
# jni_func(..) { return cv_func(..); }
ret
=
"return "
ext
=
""
default
=
"return 0"
if
fi
.
ctype
==
"void"
:
ret
=
""
default
=
""
elif
fi
.
ctype
==
"string"
:
ret
=
"return env->NewStringUTF"
ext
=
".c_str()"
default
=
'return env->NewStringUTF("")'
elif
fi
.
ctype
in
self
.
classes
:
# wrapped class:
ret
=
"return (jlong) new "
+
self
.
classes
[
fi
.
ctype
]
.
jname
...
...
@@ -537,9 +540,22 @@ class JavaWrapperGenerator(object):
JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname
($args)
{
try {
//LOGD("$module::$fname()");
$j2cv
$ret( $cvname( $cvargs )$ext );
} catch(cv::Exception e) {
//LOGD("$module::$fname() catched cv::Exception:
%
s", e.what());
jclass je = env->FindClass("org/opencv/CvException");
if(!je) je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, e.what());
$default;
} catch (...) {
//LOGD("$module::$fname() catched ...");
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, "Unknown exception in JNI code {$module::$fname()}");
$default;
}
}
...
...
@@ -553,6 +569,7 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_$fname
cvname
=
cvname
,
\
cvargs
=
", "
.
join
([
a
for
a
in
cvargs
]),
\
ext
=
ext
,
\
default
=
default
)
)
# processing args with default values
...
...
modules/java/src/java/CvException.java
0 → 100644
View file @
4033d832
package
org
.
opencv
;
public
class
CvException
extends
Exception
{
private
static
final
long
serialVersionUID
=
1L
;
public
CvException
(
String
msg
)
{
super
(
msg
);
}
@Override
public
String
toString
()
{
return
"CvException ["
+
super
.
toString
()
+
"]"
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment