You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/10 22:29:17 UTC
svn commit: r473505 - in /incubator/harmony/enhanced/drlvm/trunk/vm:
tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java
vmcore/include/version_svn_tag.h vmcore/src/jvmti/jvmti_event.cpp
Author: gshimansky
Date: Fri Nov 10 13:29:16 2006
New Revision: 473505
URL: http://svn.apache.org/viewvc?view=rev&rev=473505
Log:
Applied HARMONY-2142 [DRLVM][JVMTI] NativeMethodBind event is generated while disabled
Also added forgotten unit test from HARMONY-1931
Tests passed on winxp and ubuntu
Added:
incubator/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java
Modified:
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
Added: incubator/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java?view=auto&rev=473505
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java (added)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/tests/kernel/java/lang/reflect/LocalClassAccessCheckTest.java Fri Nov 10 13:29:16 2006
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package java.lang.reflect;
+
+import junit.framework.TestCase;
+import java.lang.reflect.InvocationTargetException;
+
+public class LocalClassAccessCheckTest extends TestCase {
+
+ private class PrivateInnerClass {
+ public void publicMethod () {
+ }
+ }
+
+ public class InnerClass {
+ public void invokeLocalClassMethod() throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException {
+ class LocalClass {
+ public void localMethod() {
+ }
+ };
+ LocalClass localClass = new LocalClass();
+ localClass.localMethod();
+ localClass.getClass().getMethod("localMethod", (Class[])null).invoke(localClass, (Object[])null);
+ }
+
+ public void invokePrivateInnerClassPublicMethod() {
+ class LocalClass {
+ public void localMethod() throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException {
+ PrivateInnerClass pic = new PrivateInnerClass();
+ pic.publicMethod();
+ pic.getClass().getMethod("publicMethod", (Class[])null).invoke(pic, (Object[])null);;
+ }
+ };
+ LocalClass localClass = new LocalClass();
+ try {
+ localClass.localMethod();
+ localClass.getClass().getMethod("localMethod", (Class[])null).invoke(localClass, (Object[])null);
+ } catch (Exception e) {
+ fail(e + " has been thrown");
+ }
+ }
+ }
+
+ public void testAccessLocalClassMethod() {
+ InnerClass ic = new InnerClass();
+ try {
+ ic.invokeLocalClassMethod();
+ } catch (Exception e) {
+ fail(e + " has been thrown");
+ }
+ }
+
+ public void testAccessInnerClassFromLocalClass() {
+ InnerClass ic = new InnerClass();
+ try {
+ ic.invokePrivateInnerClassPublicMethod();
+ } catch (Exception e) {
+ fail(e + " has been thrown");
+ }
+ }
+}
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h?view=diff&rev=473505&r1=473504&r2=473505
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/version_svn_tag.h Fri Nov 10 13:29:16 2006
@@ -18,6 +18,6 @@
#ifndef _VERSION_SVN_TAG_
#define _VERSION_SVN_TAG_
-#define VERSION_SVN_TAG "473330"
+#define VERSION_SVN_TAG "473417"
#endif // _VERSION_SVN_TAG_
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp?view=diff&rev=473505&r1=473504&r2=473505
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_event.cpp Fri Nov 10 13:29:16 2006
@@ -868,26 +868,59 @@
//Checking current phase
jvmtiPhase phase = ti->getPhase();
- if( phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE && phase != JVMTI_PHASE_PRIMORDIAL)
+ if( phase != JVMTI_PHASE_START && phase != JVMTI_PHASE_LIVE &&
+ phase != JVMTI_PHASE_PRIMORDIAL)
return;
- TRACE2("jvmti.event.bind", "Native method bind event is called for method:"
- << (method ? class_get_name(method_get_class((Method*)method)) : "(nil)") << "."
- << (method ? method_get_name((Method*)method) : "(nil)")
- << (method ? method_get_descriptor((Method*)method) : "" ) );
-
- jthread thread = getCurrentThread();
+ hythread_t thread = hythread_self();
+ jthread j_thread = jthread_get_java_thread(thread);
JNIEnv *jni_env = p_TLS_vmthread->jni_env;
- for( TIEnv *ti_env = ti->getEnvironments(); ti_env; ti_env = ti_env->next ) {
- //Must possess capability
- jvmtiCapabilities capa;
- if( JVMTI_ERROR_NONE != ((jvmtiEnv *)ti_env)->GetCapabilities(&capa) )
- return;
- if( !capa.can_generate_native_method_bind_events )
- return;
- if (NULL != ti_env->event_table.NativeMethodBind)
- ti_env->event_table.NativeMethodBind((jvmtiEnv *)ti_env, jni_env, thread, method, address, new_address_ptr);
+ TIEnv* next_env;
+ for (TIEnv* env = ti->getEnvironments(); env; env = next_env)
+ {
+ next_env = env->next;
+
+ jvmtiEventNativeMethodBind callback =
+ env->event_table.NativeMethodBind;
+
+ if (NULL == callback)
+ continue;
+
+ if (env->global_events[JVMTI_EVENT_NATIVE_METHOD_BIND - JVMTI_MIN_EVENT_TYPE_VAL])
+ {
+ TRACE2("jvmti.event.bind", "Calling global NativeMethodBind event for method:"
+ << (method ? class_get_name(method_get_class((Method*)method)) : "(nil)") << "."
+ << (method ? method_get_name((Method*)method) : "(nil)")
+ << (method ? method_get_descriptor((Method*)method) : "" ) );
+
+
+ callback((jvmtiEnv*)env, jni_env,
+ j_thread, method, address, new_address_ptr);
+
+ continue;
+ }
+
+ TIEventThread *next_et;
+ TIEventThread *first_et =
+ env->event_threads[JVMTI_EVENT_NATIVE_METHOD_BIND - JVMTI_MIN_EVENT_TYPE_VAL];
+
+ for (TIEventThread *et = first_et; NULL != et; et = next_et)
+ {
+ next_et = et->next;
+
+ if (et->thread == thread)
+ {
+ TRACE2("jvmti.event.bind", "Calling local NativeMethodBind event for method:"
+ << (method ? class_get_name(method_get_class((Method*)method)) : "(nil)") << "."
+ << (method ? method_get_name((Method*)method) : "(nil)")
+ << (method ? method_get_descriptor((Method*)method) : "" ) );
+
+
+ callback((jvmtiEnv *)env, jni_env,
+ j_thread, method, address, new_address_ptr);
+ }
+ }
}
}