Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 17 | #include <unistd.h> |
| 18 | |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 19 | #include "class_linker.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 20 | #include "class_loader.h" |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 21 | #include "dex_file.h" |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 22 | #include "image.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 23 | #include "jni_internal.h" |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 24 | #include "logging.h" |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 25 | #include "os.h" |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 26 | #include "runtime.h" |
Ian Rogers | c981848 | 2012-01-11 08:52:51 -0800 | [diff] [blame] | 27 | #include "ScopedLocalRef.h" |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 28 | #include "ScopedUtfChars.h" |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 29 | #include "space.h" |
| 30 | #include "toStringArray.h" |
| 31 | #include "zip_archive.h" |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 32 | |
| 33 | namespace art { |
| 34 | |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 35 | // A smart pointer that provides read-only access to a Java string's UTF chars. |
| 36 | // Unlike libcore's NullableScopedUtfChars, this will *not* throw NullPointerException if |
| 37 | // passed a null jstring. The correct idiom is: |
| 38 | // |
| 39 | // NullableScopedUtfChars name(env, javaName); |
Brian Carlstrom | c252c3e | 2011-10-16 23:21:02 -0700 | [diff] [blame] | 40 | // if (env->ExceptionCheck()) { |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 41 | // return NULL; |
| 42 | // } |
| 43 | // // ... use name.c_str() |
| 44 | // |
| 45 | // TODO: rewrite to get rid of this, or change ScopedUtfChars to offer this option. |
| 46 | class NullableScopedUtfChars { |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 47 | public: |
| 48 | NullableScopedUtfChars(JNIEnv* env, jstring s) : mEnv(env), mString(s) { |
| 49 | mUtfChars = (s != NULL) ? env->GetStringUTFChars(s, NULL) : NULL; |
| 50 | } |
| 51 | |
| 52 | ~NullableScopedUtfChars() { |
| 53 | if (mUtfChars) { |
| 54 | mEnv->ReleaseStringUTFChars(mString, mUtfChars); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 55 | } |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 56 | } |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 57 | |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 58 | const char* c_str() const { |
| 59 | return mUtfChars; |
| 60 | } |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 61 | |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 62 | size_t size() const { |
| 63 | return strlen(mUtfChars); |
| 64 | } |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 65 | |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 66 | // Element access. |
| 67 | const char& operator[](size_t n) const { |
| 68 | return mUtfChars[n]; |
| 69 | } |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 70 | |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 71 | private: |
| 72 | JNIEnv* mEnv; |
| 73 | jstring mString; |
| 74 | const char* mUtfChars; |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 75 | |
Elliott Hughes | ba8eee1 | 2012-01-24 20:25:24 -0800 | [diff] [blame] | 76 | // Disallow copy and assignment. |
| 77 | NullableScopedUtfChars(const NullableScopedUtfChars&); |
| 78 | void operator=(const NullableScopedUtfChars&); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
jeffhao | c393a4f | 2011-10-19 13:46:09 -0700 | [diff] [blame] | 81 | static jint DexFile_openDexFile(JNIEnv* env, jclass, jstring javaSourceName, jstring javaOutputName, jint) { |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 82 | ScopedUtfChars sourceName(env, javaSourceName); |
| 83 | if (sourceName.c_str() == NULL) { |
| 84 | return 0; |
| 85 | } |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 86 | std::string source(sourceName.c_str()); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 87 | NullableScopedUtfChars outputName(env, javaOutputName); |
Brian Carlstrom | c252c3e | 2011-10-16 23:21:02 -0700 | [diff] [blame] | 88 | if (env->ExceptionCheck()) { |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 89 | return 0; |
| 90 | } |
jeffhao | c393a4f | 2011-10-19 13:46:09 -0700 | [diff] [blame] | 91 | const DexFile* dex_file; |
| 92 | if (outputName.c_str() == NULL) { |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 93 | dex_file = Runtime::Current()->GetClassLinker()->FindDexFileInOatFileFromDexLocation(source); |
jeffhao | c393a4f | 2011-10-19 13:46:09 -0700 | [diff] [blame] | 94 | } else { |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 95 | std::string output(outputName.c_str()); |
| 96 | dex_file = Runtime::Current()->GetClassLinker()->FindOrCreateOatFileForDexLocation(source, output); |
jeffhao | c393a4f | 2011-10-19 13:46:09 -0700 | [diff] [blame] | 97 | } |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 98 | if (dex_file == NULL) { |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 99 | LOG(WARNING) << "Failed to open dex file: " << source; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 100 | Thread::Current()->ThrowNewExceptionF("Ljava/io/IOException;", "Unable to open dex file: %s", |
| 101 | source.c_str()); |
jeffhao | c393a4f | 2011-10-19 13:46:09 -0700 | [diff] [blame] | 102 | return 0; |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 103 | } |
| 104 | return static_cast<jint>(reinterpret_cast<uintptr_t>(dex_file)); |
| 105 | } |
| 106 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 107 | static const DexFile* toDexFile(int dex_file_address) { |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 108 | const DexFile* dex_file = reinterpret_cast<const DexFile*>(static_cast<uintptr_t>(dex_file_address)); |
Elliott Hughes | b3e66df | 2012-01-12 14:49:18 -0800 | [diff] [blame] | 109 | if (dex_file == NULL) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 110 | Thread::Current()->ThrowNewExceptionF("Ljava/lang/NullPointerException;", "dex_file == null"); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 111 | } |
| 112 | return dex_file; |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 113 | } |
| 114 | |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 115 | static void DexFile_closeDexFile(JNIEnv*, jclass, jint cookie) { |
| 116 | const DexFile* dex_file = toDexFile(cookie); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 117 | if (dex_file == NULL) { |
| 118 | return; |
| 119 | } |
| 120 | if (Runtime::Current()->GetClassLinker()->IsDexFileRegistered(*dex_file)) { |
| 121 | return; |
| 122 | } |
| 123 | delete dex_file; |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 126 | static jclass DexFile_defineClassNative(JNIEnv* env, jclass, jstring javaName, jobject javaLoader, |
| 127 | jint cookie) { |
Elliott Hughes | 34e0696 | 2012-04-09 13:55:55 -0700 | [diff] [blame] | 128 | ScopedThreadStateChange tsc(Thread::Current(), kRunnable); |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 129 | const DexFile* dex_file = toDexFile(cookie); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 130 | if (dex_file == NULL) { |
| 131 | return NULL; |
| 132 | } |
Brian Carlstrom | df14324 | 2011-10-10 18:05:34 -0700 | [diff] [blame] | 133 | ScopedUtfChars class_name(env, javaName); |
| 134 | if (class_name.c_str() == NULL) { |
| 135 | return NULL; |
| 136 | } |
Elliott Hughes | 9557241 | 2011-12-13 18:14:20 -0800 | [diff] [blame] | 137 | const std::string descriptor(DotToDescriptor(class_name.c_str())); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 138 | const DexFile::ClassDef* dex_class_def = dex_file->FindClassDef(descriptor); |
| 139 | if (dex_class_def == NULL) { |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 140 | return NULL; |
| 141 | } |
| 142 | |
| 143 | Object* class_loader_object = Decode<Object*>(env, javaLoader); |
| 144 | ClassLoader* class_loader = down_cast<ClassLoader*>(class_loader_object); |
| 145 | ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); |
| 146 | class_linker->RegisterDexFile(*dex_file); |
| 147 | Class* result = class_linker->DefineClass(descriptor, class_loader, *dex_file, *dex_class_def); |
| 148 | return AddLocalReference<jclass>(env, result); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 151 | static jobjectArray DexFile_getClassNameList(JNIEnv* env, jclass, jint cookie) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 152 | const DexFile* dex_file = toDexFile(cookie); |
Brian Carlstrom | aded5f7 | 2011-10-07 17:15:04 -0700 | [diff] [blame] | 153 | if (dex_file == NULL) { |
| 154 | return NULL; |
| 155 | } |
Brian Carlstrom | 03a20ba | 2011-10-13 10:24:13 -0700 | [diff] [blame] | 156 | |
| 157 | std::vector<std::string> class_names; |
| 158 | for (size_t i = 0; i < dex_file->NumClassDefs(); ++i) { |
| 159 | const DexFile::ClassDef& class_def = dex_file->GetClassDef(i); |
| 160 | const char* descriptor = dex_file->GetClassDescriptor(class_def); |
| 161 | class_names.push_back(DescriptorToDot(descriptor)); |
| 162 | } |
| 163 | return toStringArray(env, class_names); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Elliott Hughes | 0512f02 | 2012-03-15 22:10:52 -0700 | [diff] [blame] | 166 | static jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 167 | bool debug_logging = false; |
| 168 | |
Brian Carlstrom | 03a20ba | 2011-10-13 10:24:13 -0700 | [diff] [blame] | 169 | ScopedUtfChars filename(env, javaFilename); |
| 170 | if (filename.c_str() == NULL) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 171 | LOG(ERROR) << "DexFile_isDexOptNeeded null filename"; |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 172 | return JNI_TRUE; |
Brian Carlstrom | 03a20ba | 2011-10-13 10:24:13 -0700 | [diff] [blame] | 173 | } |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 174 | |
| 175 | if (!OS::FileExists(filename.c_str())) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 176 | LOG(ERROR) << "DexFile_isDexOptNeeded file '" << filename.c_str() << "' does not exist"; |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 177 | Thread::Current()->ThrowNewExceptionF("Ljava/io/FileNotFoundException;", "%s", filename.c_str()); |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 178 | return JNI_TRUE; |
| 179 | } |
| 180 | |
| 181 | // Always treat elements of the bootclasspath as up-to-date. The |
| 182 | // fact that code is running at all means that this should be true. |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 183 | Runtime* runtime = Runtime::Current(); |
| 184 | ClassLinker* class_linker = runtime->GetClassLinker(); |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 185 | const std::vector<const DexFile*>& boot_class_path = class_linker->GetBootClassPath(); |
| 186 | for (size_t i = 0; i < boot_class_path.size(); i++) { |
| 187 | if (boot_class_path[i]->GetLocation() == filename.c_str()) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 188 | if (debug_logging) { |
| 189 | LOG(INFO) << "DexFile_isDexOptNeeded ignoring boot class path file: " << filename.c_str(); |
| 190 | } |
Brian Carlstrom | 1d9f52b | 2011-10-13 10:50:45 -0700 | [diff] [blame] | 191 | return JNI_FALSE; |
| 192 | } |
| 193 | } |
| 194 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 195 | // If we have an oat file next to the dex file, assume up-to-date. |
| 196 | // A user build looks like this, and it will have no classes.dex in |
| 197 | // the input for checksum validation. |
| 198 | std::string oat_filename(OatFile::DexFilenameToOatFilename(filename.c_str())); |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 199 | UniquePtr<const OatFile> oat_file( |
| 200 | OatFile::Open(oat_filename, oat_filename, NULL, OatFile::kRelocNone)); |
Brian Carlstrom | 58cbbc2 | 2012-03-29 17:52:00 -0700 | [diff] [blame] | 201 | if (oat_file.get() != NULL && oat_file->GetOatDexFile(filename.c_str()) != NULL) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 202 | if (debug_logging) { |
| 203 | LOG(INFO) << "DexFile_isDexOptNeeded ignoring precompiled file: " << filename.c_str(); |
| 204 | } |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 205 | return JNI_FALSE; |
Brian Carlstrom | fad7143 | 2011-10-16 20:25:10 -0700 | [diff] [blame] | 206 | } |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 207 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 208 | // Check if we have an oat file in the cache |
| 209 | std::string cache_location(GetArtCacheFilenameOrDie(oat_filename)); |
Logan Chien | 0c717dd | 2012-03-28 18:31:07 +0800 | [diff] [blame] | 210 | oat_file.reset( |
| 211 | OatFile::Open(cache_location, oat_filename, NULL, OatFile::kRelocNone)); |
Brian Carlstrom | 58cbbc2 | 2012-03-29 17:52:00 -0700 | [diff] [blame] | 212 | if (oat_file.get() == NULL) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 213 | LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 214 | << " does not exist for " << filename.c_str(); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 215 | return JNI_TRUE; |
| 216 | } |
| 217 | |
Brian Carlstrom | 81f3ca1 | 2012-03-17 00:27:35 -0700 | [diff] [blame] | 218 | const ImageHeader& image_header = runtime->GetHeap()->GetImageSpace()->GetImageHeader(); |
| 219 | if (oat_file->GetOatHeader().GetImageFileLocationChecksum() != image_header.GetOatChecksum()) { |
| 220 | LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 221 | << " has out-of-date checksum compared to " |
| 222 | << image_header.GetImageRoot(ImageHeader::kOatLocation)->AsString()->ToModifiedUtf8(); |
| 223 | return JNI_TRUE; |
| 224 | } |
| 225 | |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 226 | const OatFile::OatDexFile* oat_dex_file = oat_file->GetOatDexFile(filename.c_str()); |
| 227 | if (oat_dex_file == NULL) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 228 | LOG(ERROR) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 229 | << " does not contain contents for " << filename.c_str(); |
| 230 | std::vector<const OatFile::OatDexFile*> oat_dex_files = oat_file->GetOatDexFiles(); |
| 231 | for (size_t i = 0; i < oat_dex_files.size(); i++) { |
| 232 | const OatFile::OatDexFile* oat_dex_file = oat_dex_files[i]; |
| 233 | LOG(ERROR) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 234 | << " contains contents for " << oat_dex_file->GetDexFileLocation(); |
| 235 | } |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 236 | return JNI_TRUE; |
| 237 | } |
| 238 | |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 239 | uint32_t location_checksum; |
| 240 | if (!DexFile::GetChecksum(filename.c_str(), location_checksum)) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 241 | LOG(ERROR) << "DexFile_isDexOptNeeded failed to compute checksum of " << filename.c_str(); |
Brian Carlstrom | a004aa9 | 2012-02-08 18:05:09 -0800 | [diff] [blame] | 242 | return JNI_TRUE; |
| 243 | } |
| 244 | |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 245 | if (location_checksum != oat_dex_file->GetDexFileLocationChecksum()) { |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 246 | LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 247 | << " has out-of-date checksum compared to " << filename.c_str(); |
Brian Carlstrom | 5b332c8 | 2012-02-01 15:02:31 -0800 | [diff] [blame] | 248 | return JNI_TRUE; |
| 249 | } |
| 250 | |
Brian Carlstrom | bf2cb16 | 2012-02-27 17:49:19 -0800 | [diff] [blame] | 251 | if (debug_logging) { |
| 252 | LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location |
| 253 | << " is up-to-date for " << filename.c_str(); |
| 254 | } |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 255 | return JNI_FALSE; |
| 256 | } |
| 257 | |
| 258 | static JNINativeMethod gMethods[] = { |
| 259 | NATIVE_METHOD(DexFile, closeDexFile, "(I)V"), |
Ian Rogers | 66a556f | 2012-02-14 00:05:38 -0800 | [diff] [blame] | 260 | NATIVE_METHOD(DexFile, defineClassNative, "(Ljava/lang/String;Ljava/lang/ClassLoader;I)Ljava/lang/Class;"), |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 261 | NATIVE_METHOD(DexFile, getClassNameList, "(I)[Ljava/lang/String;"), |
| 262 | NATIVE_METHOD(DexFile, isDexOptNeeded, "(Ljava/lang/String;)Z"), |
| 263 | NATIVE_METHOD(DexFile, openDexFile, "(Ljava/lang/String;Ljava/lang/String;I)I"), |
| 264 | }; |
| 265 | |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 266 | void register_dalvik_system_DexFile(JNIEnv* env) { |
Elliott Hughes | eac7667 | 2012-05-24 21:56:51 -0700 | [diff] [blame] | 267 | REGISTER_NATIVE_METHODS("dalvik/system/DexFile"); |
Brian Carlstrom | f91c8c3 | 2011-09-21 17:30:34 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | } // namespace art |