4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <dtrace_jni.h>
32 * This file creates instances of the Java class
33 * org.opensolaris.os.dtrace.InterfaceAttributes.
37 dtj_stability_name(dtrace_stability_t stability
)
41 case DTRACE_STABILITY_INTERNAL
:
44 case DTRACE_STABILITY_PRIVATE
:
47 case DTRACE_STABILITY_OBSOLETE
:
50 case DTRACE_STABILITY_EXTERNAL
:
53 case DTRACE_STABILITY_UNSTABLE
:
56 case DTRACE_STABILITY_EVOLVING
:
59 case DTRACE_STABILITY_STABLE
:
62 case DTRACE_STABILITY_STANDARD
:
73 dtj_dependency_class_name(dtrace_class_t
class)
77 case DTRACE_CLASS_UNKNOWN
:
80 case DTRACE_CLASS_CPU
:
83 case DTRACE_CLASS_PLATFORM
:
86 case DTRACE_CLASS_GROUP
:
89 case DTRACE_CLASS_ISA
:
92 case DTRACE_CLASS_COMMON
:
103 dtj_new_attribute(dtj_java_consumer_t
*jc
, const dtrace_attribute_t
*attr
)
105 JNIEnv
*jenv
= jc
->dtjj_jenv
;
109 jstring jname
= NULL
;
110 jobject jattr
= NULL
; /* return value */
112 jattr
= (*jenv
)->NewObject(jenv
, g_attr_jc
, g_attrinit_jm
);
113 if ((*jenv
)->ExceptionCheck(jenv
)) {
118 name
= dtj_stability_name(attr
->dtat_name
);
120 dtj_throw_illegal_argument(jenv
,
121 "unexpected name stability value: %d",
123 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
126 jname
= (*jenv
)->NewStringUTF(jenv
, name
);
127 if ((*jenv
)->ExceptionCheck(jenv
)) {
128 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
131 (*jenv
)->CallVoidMethod(jenv
, jattr
, g_attrset_name_jm
, jname
);
132 (*jenv
)->DeleteLocalRef(jenv
, jname
);
133 if ((*jenv
)->ExceptionCheck(jenv
)) {
134 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
139 name
= dtj_stability_name(attr
->dtat_data
);
141 dtj_throw_illegal_argument(jenv
,
142 "unexpected data stability value: %d",
144 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
147 jname
= (*jenv
)->NewStringUTF(jenv
, name
);
148 if ((*jenv
)->ExceptionCheck(jenv
)) {
149 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
152 (*jenv
)->CallVoidMethod(jenv
, jattr
, g_attrset_data_jm
, jname
);
153 (*jenv
)->DeleteLocalRef(jenv
, jname
);
154 if ((*jenv
)->ExceptionCheck(jenv
)) {
155 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
159 /* dependency class */
160 name
= dtj_dependency_class_name(attr
->dtat_class
);
162 dtj_throw_illegal_argument(jenv
,
163 "unexpected dependency class value: %d",
165 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
168 jname
= (*jenv
)->NewStringUTF(jenv
, name
);
169 if ((*jenv
)->ExceptionCheck(jenv
)) {
170 (*jenv
)->DeleteLocalRef(jenv
, jattr
);
173 (*jenv
)->CallVoidMethod(jenv
, jattr
, g_attrset_class_jm
, jname
);
174 (*jenv
)->DeleteLocalRef(jenv
, jname
);
175 if ((*jenv
)->ExceptionCheck(jenv
)) {
176 (*jenv
)->DeleteLocalRef(jenv
, jattr
);