| 1 | /***************************************************************************** |
| 2 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | you may not use this file except in compliance with the License. |
| 4 | You may obtain a copy of the License at |
| 5 | |
| 6 | http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | |
| 8 | Unless required by applicable law or agreed to in writing, software |
| 9 | distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | See the License for the specific language governing permissions and |
| 12 | limitations under the License. |
| 13 | |
| 14 | See NOTICE file for details. |
| 15 | *****************************************************************************/ |
| 16 | #ifndef _JPCLASSLOADER_H_ |
| 17 | #define _JPCLASSLOADER_H_ |
| 18 | |
| 19 | #include "jp_class.h" |
| 20 | |
| 21 | /** |
| 22 | * The class loader is reponsible for loading classes within JPype. |
| 23 | * |
| 24 | * Depending on the settings it may either use an internal boot loader |
| 25 | * to get the jar from within the _jpype module, or it may use the |
| 26 | * system class loader. |
| 27 | */ |
| 28 | class JPClassLoader |
| 29 | { |
| 30 | public: |
| 31 | /** Initialize the class loader. |
| 32 | */ |
| 33 | explicit JPClassLoader(JPJavaFrame& frame); |
| 34 | |
| 35 | /** Load a class by name from the jpype.jar. |
| 36 | * |
| 37 | * String is specified as a Java binary name. |
| 38 | * https://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#name |
| 39 | * |
| 40 | * @returns the class loaded |
| 41 | * @throws RuntimeException if the class is not found. |
| 42 | */ |
| 43 | jclass findClass(JPJavaFrame& frame, const string& name); |
| 44 | |
| 45 | // Classloader for Proxy |
| 46 | jobject getBootLoader(); |
| 47 | |
| 48 | private: |
| 49 | JPClassRef m_ClassClass; |
| 50 | JPObjectRef m_SystemClassLoader; |
| 51 | JPObjectRef m_BootLoader; |
| 52 | jmethodID m_ForNameID; |
| 53 | } ; |
| 54 | |
| 55 | #endif // _JPCLASSLOADER_H_ |