1 /* 2 * Copyright (C) 2007 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 17 package dalvik.system; 18 19 /** 20 * Fake class used during JNI initialization. The JNI functions want 21 * to be able to create objects, and the VM needs to discard the references 22 * when the function returns. That gets a little weird when we're 23 * calling JNI functions from the C main(), and there's no Java stack frame 24 * to hitch the references onto. 25 * 26 * Rather than having some special-case code, we create this simple little 27 * class and pretend that it called the C main(). 28 * 29 * This also comes in handy when a native thread attaches itself with the 30 * JNI AttachCurrentThread call. If they attach the thread and start 31 * creating objects, we need a fake frame to store stuff in. 32 */ 33 class NativeStart { NativeStart()34 private NativeStart() {} 35 main(String[] fake)36 private static native void main(String[] fake); 37 run()38 private static native void run(); 39 } 40