1 /* 2 * Copyright (c) 2011, 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 23 * questions. 24 */ 25 26 #import <jni.h> 27 #import <pthread.h> 28 #import <QuartzCore/CVDisplayLink.h> 29 #import "GlassStatics.h" 30 #import "GlassMacros.h" 31 32 pthread_key_t GlassThreadDataKey = 0; 33 34 CVDisplayLinkRef GlassDisplayLink = NULL; 35 36 JavaVM *jVM = NULL; 37 JNIEnv *jEnv = NULL; 38 39 jclass jApplicationClass = NULL; 40 jclass jWindowClass = NULL; 41 jclass jViewClass = NULL; 42 43 jclass jScreenClass = NULL; 44 jclass jMenuBarDelegateClass = NULL; 45 jclass jIntegerClass = NULL; 46 jclass jLongClass = NULL; 47 jclass jMapClass = NULL; 48 jclass jBooleanClass = NULL; 49 50 jmethodID jRunnableRun = NULL; 51 52 jmethodID jWindowNotifyMove = NULL; 53 jmethodID jWindowNotifyResize = NULL; 54 jmethodID jWindowNotifyClose = NULL; 55 jmethodID jWindowNotifyMoveToAnotherScreen = NULL; 56 jmethodID jWindowNotifyFocus = NULL; 57 jmethodID jWindowNotifyFocusUngrab = NULL; 58 jmethodID jWindowNotifyFocusDisabled = NULL; 59 jmethodID jWindowNotifyDestroy = NULL; 60 jmethodID jWindowNotifyDelegatePtr = NULL; 61 62 jmethodID jViewNotifyEvent = NULL; 63 jmethodID jViewNotifyRepaint = NULL; 64 jmethodID jViewNotifyResize = NULL; 65 jmethodID jViewNotifyKey = NULL; 66 jmethodID jViewNotifyMouse = NULL; 67 jmethodID jViewNotifyMenu = NULL; 68 jmethodID jViewNotifyInputMethod = NULL; 69 jmethodID jViewNotifyInputMethodMac = NULL; 70 jmethodID jViewNotifyInputMethodCandidatePosRequest = NULL; 71 jmethodID jViewNotifyDragEnter = NULL; 72 jmethodID jViewNotifyDragOver = NULL; 73 jmethodID jViewNotifyDragLeave = NULL; 74 jmethodID jViewNotifyDragDrop = NULL; 75 jmethodID jViewNotifyDragEnd = NULL; 76 jmethodID jViewGetAccessible = NULL; 77 78 jmethodID jScreenNotifySettingsChanged = NULL; 79 80 jmethodID jMapGetMethod = NULL; 81 jmethodID jBooleanValueMethod = NULL; 82 jmethodID jIntegerInitMethod = NULL; 83 jmethodID jIntegerValueMethod = NULL; 84 jmethodID jLongValueMethod = NULL; 85 86 jmethodID jSizeInit = NULL; 87 88 jmethodID jPixelsAttachData = NULL; 89 90 JavaIDs javaIDs; 91 92 void initJavaIDsList(JNIEnv* env) 93 { 94 if (!javaIDs.List.add) { 95 jclass jcls = (*env)->FindClass(env, "java/util/List"); 96 GLASS_CHECK_EXCEPTION(env); 97 if (jcls) { 98 javaIDs.List.add = (*env)->GetMethodID(env, jcls, "add", "(Ljava/lang/Object;)Z"); 99 GLASS_CHECK_EXCEPTION(env); 100 } 101 } 102 } 103 104 void initJavaIDsArrayList(JNIEnv* env) 105 { 106 if (!javaIDs.ArrayList.init) { 107 jclass jcls = (*env)->FindClass(env, "java/util/ArrayList"); 108 GLASS_CHECK_EXCEPTION(env); 109 if (jcls) { 110 javaIDs.ArrayList.init = (*env)->GetMethodID(env, jcls, "<init>", "()V"); 111 GLASS_CHECK_EXCEPTION(env); 112 } 113 } 114 } 115 116 void initJavaIDsFile(JNIEnv* env) 117 { 118 if (!javaIDs.File.init) { 119 jclass jcls = (*env)->FindClass(env, "java/io/File"); 120 GLASS_CHECK_EXCEPTION(env); 121 if (jcls) { 122 javaIDs.File.init = (*env)->GetMethodID(env, jcls, "<init>", "(Ljava/lang/String;)V"); 123 GLASS_CHECK_EXCEPTION(env); 124 } 125 } 126 } 127