50 methods, sizeof(methods)/sizeof(methods[0]));
51 }
52
53 JNIEXPORT jint JNICALL
54 Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
55 {
56 return JVM_IHashCode(env, x);
57 }
58
59 #define PUTPROP(props, key, val) \
60 if (1) { \
61 jstring jkey = (*env)->NewStringUTF(env, key); \
62 jstring jval = (*env)->NewStringUTF(env, val); \
63 jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
64 if ((*env)->ExceptionOccurred(env)) return NULL; \
65 (*env)->DeleteLocalRef(env, jkey); \
66 (*env)->DeleteLocalRef(env, jval); \
67 (*env)->DeleteLocalRef(env, r); \
68 } else ((void) 0)
69
70 #define PUTPROP_ForPlatformCString(props, key, val) \
71 if (1) { \
72 jstring jkey = JNU_NewStringPlatform(env, key); \
73 jstring jval = JNU_NewStringPlatform(env, val); \
74 jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
75 if ((*env)->ExceptionOccurred(env)) return NULL; \
76 (*env)->DeleteLocalRef(env, jkey); \
77 (*env)->DeleteLocalRef(env, jval); \
78 (*env)->DeleteLocalRef(env, r); \
79 } else ((void) 0)
80
81 #ifndef VENDOR /* Third party may overwrite this. */
82 #define VENDOR "Sun Microsystems Inc."
83 #define VENDOR_URL "http://java.sun.com/"
84 #define VENDOR_URL_BUG "http://java.sun.com/cgi-bin/bugreport.cgi"
85 #endif
86
87 #define JAVA_MAX_SUPPORTED_VERSION 50
88 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
89
90 JNIEXPORT jobject JNICALL
91 Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
92 {
93 char buf[128];
133 * user.country, user.variant (if user's environment specifies them)
134 * file.encoding
135 * file.encoding.pkg
136 */
137 PUTPROP(props, "user.language", sprops->language);
138 if (sprops->country) {
139 PUTPROP(props, "user.country", sprops->country);
140 }
141 if (sprops->variant) {
142 PUTPROP(props, "user.variant", sprops->variant);
143 }
144 PUTPROP(props, "file.encoding", sprops->encoding);
145 PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
146 PUTPROP(props, "file.encoding.pkg", "sun.io");
147 /* unicode_encoding specifies the default endianness */
148 PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
149 PUTPROP(props, "sun.cpu.isalist",
150 (sprops->cpu_isalist ? sprops->cpu_isalist : ""));
151 PUTPROP(props, "sun.cpu.endian", sprops->cpu_endian);
152
153 /* !!! DO NOT call PUTPROP_ForPlatformCString before this line !!!
154 * !!! I18n properties have not been set up yet !!!
155 */
156
157 /* Printing properties */
158 /* Note: java.awt.printerjob is an implementation private property which
159 * just happens to have a java.* name because it is referenced in
160 * a java.awt class. It is the mechanism by which the Sun implementation
161 * finds the appropriate class in the JRE for the platform.
162 * It is explicitly not designed to be overridden by clients as
163 * a way of replacing the implementation class, and in any case
164 * the mechanism by which the class is loaded is constrained to only
165 * find and load classes that are part of the JRE.
166 * This property may be removed if that mechanism is redesigned
167 */
168 PUTPROP(props, "java.awt.printerjob", sprops->printerJob);
169
170 /* data model */
171 if (sizeof(sprops) == 4) {
172 sprops->data_model = "32";
173 } else if (sizeof(sprops) == 8) {
178 PUTPROP(props, "sun.arch.data.model", \
179 sprops->data_model);
180
181 /* patch level */
182 PUTPROP(props, "sun.os.patch.level", \
183 sprops->patch_level);
184
185 /* Java2D properties */
186 /* Note: java.awt.graphicsenv is an implementation private property which
187 * just happens to have a java.* name because it is referenced in
188 * a java.awt class. It is the mechanism by which the Sun implementation
189 * finds the appropriate class in the JRE for the platform.
190 * It is explicitly not designed to be overridden by clients as
191 * a way of replacing the implementation class, and in any case
192 * the mechanism by which the class is loaded is constrained to only
193 * find and load classes that are part of the JRE.
194 * This property may be removed if that mechanism is redesigned
195 */
196 PUTPROP(props, "java.awt.graphicsenv", sprops->graphics_env);
197 if (sprops->font_dir != NULL) {
198 PUTPROP_ForPlatformCString(props,
199 "sun.java2d.fontpath", sprops->font_dir);
200 }
201
202 PUTPROP_ForPlatformCString(props, "java.io.tmpdir", sprops->tmp_dir);
203
204 PUTPROP_ForPlatformCString(props, "user.name", sprops->user_name);
205 PUTPROP_ForPlatformCString(props, "user.home", sprops->user_home);
206
207 PUTPROP(props, "user.timezone", sprops->timezone);
208
209 PUTPROP_ForPlatformCString(props, "user.dir", sprops->user_dir);
210
211 /* This is a sun. property as it is currently only set for Gnome and
212 * Windows desktops.
213 */
214 if (sprops->desktop != NULL) {
215 PUTPROP(props, "sun.desktop", sprops->desktop);
216 }
217
218 return JVM_InitProperties(env, props);
219 }
220
221 /*
222 * The following three functions implement setter methods for
223 * java.lang.System.{in, out, err}. They are natively implemented
224 * because they violate the semantics of the language (i.e. set final
225 * variable).
226 */
227 JNIEXPORT void JNICALL
228 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
229 {
|
50 methods, sizeof(methods)/sizeof(methods[0]));
51 }
52
53 JNIEXPORT jint JNICALL
54 Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x)
55 {
56 return JVM_IHashCode(env, x);
57 }
58
59 #define PUTPROP(props, key, val) \
60 if (1) { \
61 jstring jkey = (*env)->NewStringUTF(env, key); \
62 jstring jval = (*env)->NewStringUTF(env, val); \
63 jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
64 if ((*env)->ExceptionOccurred(env)) return NULL; \
65 (*env)->DeleteLocalRef(env, jkey); \
66 (*env)->DeleteLocalRef(env, jval); \
67 (*env)->DeleteLocalRef(env, r); \
68 } else ((void) 0)
69
70 /* "key" is a char type string with only ASCII character in it.
71 "val" is a nchar (typedefed in java_props.h) type string */
72
73 #define PUTPROP_ForPlatformNString(props, key, val) \
74 if (1) { \
75 jstring jkey = (*env)->NewStringUTF(env, key); \
76 jstring jval = GetStringPlatform(env, val); \
77 jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \
78 if ((*env)->ExceptionOccurred(env)) return NULL; \
79 (*env)->DeleteLocalRef(env, jkey); \
80 (*env)->DeleteLocalRef(env, jval); \
81 (*env)->DeleteLocalRef(env, r); \
82 } else ((void) 0)
83
84 #ifndef VENDOR /* Third party may overwrite this. */
85 #define VENDOR "Sun Microsystems Inc."
86 #define VENDOR_URL "http://java.sun.com/"
87 #define VENDOR_URL_BUG "http://java.sun.com/cgi-bin/bugreport.cgi"
88 #endif
89
90 #define JAVA_MAX_SUPPORTED_VERSION 50
91 #define JAVA_MAX_SUPPORTED_MINOR_VERSION 0
92
93 JNIEXPORT jobject JNICALL
94 Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
95 {
96 char buf[128];
136 * user.country, user.variant (if user's environment specifies them)
137 * file.encoding
138 * file.encoding.pkg
139 */
140 PUTPROP(props, "user.language", sprops->language);
141 if (sprops->country) {
142 PUTPROP(props, "user.country", sprops->country);
143 }
144 if (sprops->variant) {
145 PUTPROP(props, "user.variant", sprops->variant);
146 }
147 PUTPROP(props, "file.encoding", sprops->encoding);
148 PUTPROP(props, "sun.jnu.encoding", sprops->sun_jnu_encoding);
149 PUTPROP(props, "file.encoding.pkg", "sun.io");
150 /* unicode_encoding specifies the default endianness */
151 PUTPROP(props, "sun.io.unicode.encoding", sprops->unicode_encoding);
152 PUTPROP(props, "sun.cpu.isalist",
153 (sprops->cpu_isalist ? sprops->cpu_isalist : ""));
154 PUTPROP(props, "sun.cpu.endian", sprops->cpu_endian);
155
156 /* !!! DO NOT call PUTPROP_ForPlatformNString before this line !!!
157 * !!! I18n properties have not been set up yet !!!
158 */
159
160 /* Printing properties */
161 /* Note: java.awt.printerjob is an implementation private property which
162 * just happens to have a java.* name because it is referenced in
163 * a java.awt class. It is the mechanism by which the Sun implementation
164 * finds the appropriate class in the JRE for the platform.
165 * It is explicitly not designed to be overridden by clients as
166 * a way of replacing the implementation class, and in any case
167 * the mechanism by which the class is loaded is constrained to only
168 * find and load classes that are part of the JRE.
169 * This property may be removed if that mechanism is redesigned
170 */
171 PUTPROP(props, "java.awt.printerjob", sprops->printerJob);
172
173 /* data model */
174 if (sizeof(sprops) == 4) {
175 sprops->data_model = "32";
176 } else if (sizeof(sprops) == 8) {
181 PUTPROP(props, "sun.arch.data.model", \
182 sprops->data_model);
183
184 /* patch level */
185 PUTPROP(props, "sun.os.patch.level", \
186 sprops->patch_level);
187
188 /* Java2D properties */
189 /* Note: java.awt.graphicsenv is an implementation private property which
190 * just happens to have a java.* name because it is referenced in
191 * a java.awt class. It is the mechanism by which the Sun implementation
192 * finds the appropriate class in the JRE for the platform.
193 * It is explicitly not designed to be overridden by clients as
194 * a way of replacing the implementation class, and in any case
195 * the mechanism by which the class is loaded is constrained to only
196 * find and load classes that are part of the JRE.
197 * This property may be removed if that mechanism is redesigned
198 */
199 PUTPROP(props, "java.awt.graphicsenv", sprops->graphics_env);
200 if (sprops->font_dir != NULL) {
201 PUTPROP_ForPlatformNString(props,
202 "sun.java2d.fontpath", sprops->font_dir);
203 }
204
205 PUTPROP_ForPlatformNString(props, "java.io.tmpdir", sprops->tmp_dir);
206
207 PUTPROP_ForPlatformNString(props, "user.name", sprops->user_name);
208 PUTPROP_ForPlatformNString(props, "user.home", sprops->user_home);
209
210 PUTPROP(props, "user.timezone", sprops->timezone);
211
212 PUTPROP_ForPlatformNString(props, "user.dir", sprops->user_dir);
213
214 /* This is a sun. property as it is currently only set for Gnome and
215 * Windows desktops.
216 */
217 if (sprops->desktop != NULL) {
218 PUTPROP(props, "sun.desktop", sprops->desktop);
219 }
220
221 return JVM_InitProperties(env, props);
222 }
223
224 /*
225 * The following three functions implement setter methods for
226 * java.lang.System.{in, out, err}. They are natively implemented
227 * because they violate the semantics of the language (i.e. set final
228 * variable).
229 */
230 JNIEXPORT void JNICALL
231 Java_java_lang_System_setIn0(JNIEnv *env, jclass cla, jobject stream)
232 {
|