[kaffe] Updated patch...
Jukka Santala
jsantala at tml.hut.fi
Wed May 8 04:59:21 PDT 2002
To try to avoid further clutter, I've included the three tested main
patches into one, and would like to see these included in Kaffe to get
Xsmiles to at least start up under it (Provided CLASSPATH is right).
The only change from the posted invidual pieces is that I analyzed Sun
JDK's proxy-behaviour and tried to replicate it as close as possible,
using default port if it can't be determined for proxy and failing quietly
if proxy connection fails, re-trying automatically with direct connection.
(This may be annoying if you're using proxy for reasons such as cost etc.
but it's what Sun's JDK appears to do...). Since I already wrote the
test-case for Field, I included it as well. Naturally Klasses needs to be
rebuilt for HttpURLConnection.
Changelog entry:
Wed May 8 14:42:26 EEST 2002 Jukka Santala <jsantala at tml.hut.fi>
* kaffe/xprof/gmonFile.c: va_arg with int type to allow building
with GCC 3+
* libraries/clib/native/Class.c: Made exception match Sun JDK's.
* libraries/clib/native/Field.c: Methods aren't JNI compatible, so
named them correctly.
* libraries/javalib/kaffe/net/www/protocol/http/
HttpURLConnection.java: Made proxy address handling match Sun
JDK's observed behaviour.
* test/regression/GetField.java: Added test-case for Field
methods.
-Jukka Santala
-------------- next part --------------
import java.lang.reflect.Field;
class SomeFields {
public int SOME = 10;
protected int PSOME = 20;
}
class GetField {
public int TEST = 10;
public static int STEST = 20;
private static int PSTEST = 30;
public static void main(String args[]) {
Field fld;
Class cls = GetField.class;
try {
fld = cls.getField("TEST");
System.out.println("public: "+fld.getInt(cls));
} catch (Exception e) {
System.out.println(e);
}
try {
fld = cls.getField("STEST");
System.out.println("public static: "+fld.getInt(cls));
} catch (Exception e) {
System.out.println(e);
}
try {
fld = cls.getField("PSTEST");
System.out.println("private: "+fld.getInt(cls));
} catch (Exception e) {
System.out.println(e);
}
try {
fld = cls.getField("TEST");
System.out.println("public from null: "+fld.getInt(null));
} catch (Exception e) {
System.out.println(e);
}
try {
fld = cls.getField("STEST");
System.out.println("public static from null: "+fld.getInt(null));
} catch (Exception e) {
System.out.println(e);
}
SomeFields sFields = new SomeFields();
cls = SomeFields.class;
try {
fld = cls.getField("SOME");
System.out.println("SomeFields public: "+fld.getInt(sFields));
} catch (Exception e) {
System.out.println(e);
}
try {
fld = cls.getField("PSOME");
System.out.println("SomeFields protected: "+fld.getInt(sFields));
} catch (Exception e) {
System.out.println(e);
}
}
}
/* Expected Output:
java.lang.IllegalArgumentException
public static: 20
java.lang.NoSuchFieldException: PSTEST
java.lang.NullPointerException
public static from null: 20
SomeFields public: 10
java.lang.NoSuchFieldException: PSOME
*/
-------------- next part --------------
? HttpURL.patch
? Kaffe_Field_get.patch
? Kaffe_XS1.patch
Index: kaffe/xprof/gmonFile.c
===================================================================
RCS file: /cvs/kaffe/kaffe/kaffe/xprof/gmonFile.c,v
retrieving revision 1.1
diff -u -r1.1 gmonFile.c
--- kaffe/xprof/gmonFile.c 23 May 2000 17:55:37 -0000 1.1
+++ kaffe/xprof/gmonFile.c 8 May 2002 11:45:37 -0000
@@ -133,7 +133,7 @@
strcpy(ghh.dimen, va_arg(args, char *));
break;
case GRA_DimensionAbbrev:
- ghh.dimen_abbrev = va_arg(args, char);
+ ghh.dimen_abbrev = va_arg(args, int);
break;
case GRA_ProfilingRate:
*((int *)ghh.prof_rate) = va_arg(args, int);
Index: libraries/clib/native/Class.c
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/native/Class.c,v
retrieving revision 1.60
diff -u -r1.60 Class.c
--- libraries/clib/native/Class.c 12 Apr 2002 21:13:59 -0000 1.60
+++ libraries/clib/native/Class.c 8 May 2002 11:45:37 -0000
@@ -927,7 +927,12 @@
if (f != 0) {
return (f);
}
- SignalError("java.lang.NoSuchFieldException", ""); /* FIXME */
+ /* like SignalError, except that the name of the field that is
+ * not found becomes the error message
+ */
+ throwException((struct Hjava_lang_Throwable*)execute_java_constructor(
+ "java.lang.NoSuchFieldException", 0, 0,
+ "(Ljava/lang/String;)V", name));
}
HArrayOfObject*
Index: libraries/clib/native/Field.c
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/clib/native/Field.c,v
retrieving revision 1.14
diff -u -r1.14 Field.c
--- libraries/clib/native/Field.c 6 May 2002 02:27:33 -0000 1.14
+++ libraries/clib/native/Field.c 8 May 2002 11:45:37 -0000
@@ -81,111 +81,111 @@
}
struct Hjava_lang_Object*
-Java_java_lang_reflect_Field_getObject0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getObject0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return ((struct Hjava_lang_Object*)getFieldAddress(this, obj));
}
jboolean
-Java_java_lang_reflect_Field_getBoolean0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getBoolean0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jboolean*)getFieldAddress(this, obj));
}
jbyte
-Java_java_lang_reflect_Field_getByte0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getByte0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jbyte*)getFieldAddress(this, obj));
}
jchar
-Java_java_lang_reflect_Field_getChar0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getChar0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jchar*)getFieldAddress(this, obj));
}
jshort
-Java_java_lang_reflect_Field_getShort0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getShort0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jshort*)getFieldAddress(this, obj));
}
jint
-Java_java_lang_reflect_Field_getInt0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getInt0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jint*)getFieldAddress(this, obj));
}
jlong
-Java_java_lang_reflect_Field_getLong0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getLong0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jlong*)getFieldAddress(this, obj));
}
jfloat
-Java_java_lang_reflect_Field_getFloat0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getFloat0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jfloat*)getFieldAddress(this, obj));
}
jdouble
-Java_java_lang_reflect_Field_getDouble0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
+java_lang_reflect_Field_getDouble0(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj)
{
return (*(jdouble*)getFieldAddress(this, obj));
}
void
-Java_java_lang_reflect_Field_setBoolean(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jboolean val)
+java_lang_reflect_Field_setBoolean(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jboolean val)
{
*(jboolean*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setByte(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jbyte val)
+java_lang_reflect_Field_setByte(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jbyte val)
{
*(jbyte*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setChar(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jchar val)
+java_lang_reflect_Field_setChar(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jchar val)
{
*(jchar*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setShort(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jshort val)
+java_lang_reflect_Field_setShort(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jshort val)
{
*(jshort*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setInt(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jint val)
+java_lang_reflect_Field_setInt(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jint val)
{
*(jint*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setLong(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jlong val)
+java_lang_reflect_Field_setLong(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jlong val)
{
*(jlong*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setFloat(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jfloat val)
+java_lang_reflect_Field_setFloat(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jfloat val)
{
*(jfloat*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_setDouble(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jdouble val)
+java_lang_reflect_Field_setDouble(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, jdouble val)
{
*(jdouble*)getFieldAddress(this, obj) = val;
}
void
-Java_java_lang_reflect_Field_set(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, struct Hjava_lang_Object* val)
+java_lang_reflect_Field_set(struct Hjava_lang_reflect_Field * this, struct Hjava_lang_Object* obj, struct Hjava_lang_Object* val)
{
*(jobject*)getFieldAddress(this, obj) = val;
}
Index: libraries/javalib/Klasses.jar
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/Klasses.jar,v
retrieving revision 1.222
diff -u -r1.222 Klasses.jar
Binary files /tmp/cvsK84ObY and Klasses.jar differ
Index: libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java,v
retrieving revision 1.11
diff -u -r1.11 HttpURLConnection.java
--- libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java 4 Jan 2002 05:12:33 -0000 1.11
+++ libraries/javalib/kaffe/net/www/protocol/http/HttpURLConnection.java 8 May 2002 11:45:43 -0000
@@ -40,7 +40,7 @@
// How these properties are undocumented in the API doc. We know
// about them from www.icesoft.no's webpage
proxyHost = System.getProperty("http.proxyHost");
- if (proxyHost != null) {
+ if (proxyHost != null && !proxyHost.equals("")) {
// Sun also supports a http.nonProxyHosts property to
// avoid proxy use for local sites. It's a regular expression
// like so "*.pa.dec.com|*.compaq.com"
@@ -52,7 +52,11 @@
useProxy = true;
String pp = System.getProperty("http.proxyPort");
if (pp != null) {
- proxyPort = Integer.parseInt(pp);
+ try {
+ proxyPort = Integer.parseInt(pp);
+ } catch (NumberFormatException e) {
+ proxyPort = -1; // Make sure.
+ }
}
}
}
@@ -74,11 +78,18 @@
if (useProxy) {
port = proxyPort;
host = proxyHost;
+ if (port == -1) {
+ port = 80;
+ }
+ try {
+ sock = new Socket(host, port);
+ } catch (IOException e) {
+ // Sun JDK just ignores proxy errors.
+ }
}
- else {
- port = url.getPort();
- host = url.getHost();
- }
+
+ port = url.getPort();
+ host = url.getHost();
if (port == -1) {
port = 80;
}
More information about the kaffe
mailing list