1 /*
2 * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
50 #ifdef __APPLE__
51 /* use setjmp/longjmp versions that do not save/restore the signal mask */
52 #define setjmp _setjmp
53 #define longjmp _longjmp
54 #endif
55
56 /* The method IDs we cache. Note that the last two belongs to the
57 * java.io.InputStream class.
58 */
59 static jmethodID sendHeaderInfoID;
60 static jmethodID sendPixelsByteID;
61 static jmethodID sendPixelsIntID;
62 static jmethodID InputStream_readID;
63 static jmethodID InputStream_availableID;
64
65 /* Initialize the Java VM instance variable when the library is
66 first loaded */
67 JavaVM *jvm;
68
69 JNIEXPORT jint JNICALL
70 JNI_OnLoad(JavaVM *vm, void *reserved)
71 {
72 jvm = vm;
73 return JNI_VERSION_1_2;
74 }
75
76 /*
77 * ERROR HANDLING:
78 *
79 * The JPEG library's standard error handler (jerror.c) is divided into
80 * several "methods" which you can override individually. This lets you
81 * adjust the behavior without duplicating a lot of code, which you might
82 * have to update with each future release.
83 *
84 * Our example here shows how to override the "error_exit" method so that
85 * control is returned to the library's caller when a fatal error occurs,
86 * rather than calling exit() as the standard error_exit method does.
87 *
88 * We use C's setjmp/longjmp facility to return control. This means that the
89 * routine which calls the JPEG library must first execute a setjmp() call to
90 * establish the return point. We want the replacement error_exit to do a
|
1 /*
2 * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
50 #ifdef __APPLE__
51 /* use setjmp/longjmp versions that do not save/restore the signal mask */
52 #define setjmp _setjmp
53 #define longjmp _longjmp
54 #endif
55
56 /* The method IDs we cache. Note that the last two belongs to the
57 * java.io.InputStream class.
58 */
59 static jmethodID sendHeaderInfoID;
60 static jmethodID sendPixelsByteID;
61 static jmethodID sendPixelsIntID;
62 static jmethodID InputStream_readID;
63 static jmethodID InputStream_availableID;
64
65 /* Initialize the Java VM instance variable when the library is
66 first loaded */
67 JavaVM *jvm;
68
69 JNIEXPORT jint JNICALL
70 DEF_JNI_OnLoad(JavaVM *vm, void *reserved)
71 {
72 jvm = vm;
73 return JNI_VERSION_1_2;
74 }
75
76 /*
77 * ERROR HANDLING:
78 *
79 * The JPEG library's standard error handler (jerror.c) is divided into
80 * several "methods" which you can override individually. This lets you
81 * adjust the behavior without duplicating a lot of code, which you might
82 * have to update with each future release.
83 *
84 * Our example here shows how to override the "error_exit" method so that
85 * control is returned to the library's caller when a fatal error occurs,
86 * rather than calling exit() as the standard error_exit method does.
87 *
88 * We use C's setjmp/longjmp facility to return control. This means that the
89 * routine which calls the JPEG library must first execute a setjmp() call to
90 * establish the return point. We want the replacement error_exit to do a
|