From 22eaf0622e66dc7630e1c03124fdd0df47da2a0b Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 03:03:11 +0000 Subject: [PATCH 1/7] some simple cleanups for the script_class_loader.java --- .../game/script/script_class_loader.java | 32 +++++-------------- 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/script_class_loader.java b/sku.0/sys.server/compiled/game/script/script_class_loader.java index 358fb6dbd..70b734e88 100644 --- a/sku.0/sys.server/compiled/game/script/script_class_loader.java +++ b/sku.0/sys.server/compiled/game/script/script_class_loader.java @@ -54,13 +54,9 @@ public class script_class_loader extends ClassLoader try { myObject = myClass.newInstance(); - if (myObject != null) + if (myObject == null) { -// System.out.println("Created new script_class_loader for class " + name + " (" + myClass.getName() + ")"); - } - else - { - System.out.println("WARNING: Java Error creating object for class " + name); + System.err.println("WARNING: Java Error creating object for class " + name); } } catch ( InstantiationException err ) @@ -88,8 +84,6 @@ public class script_class_loader extends ClassLoader if (test != null) return (script_class_loader)test; -// System.out.println("script_class_loader getClassLoader creating new loader for class " + name); - if (name.indexOf("script.") != 0) { ClassNotFoundException err = new ClassNotFoundException("Class " + name + " does not start with 'script.'"); @@ -147,11 +141,10 @@ public class script_class_loader extends ClassLoader String pathedName = name.replace('.', java.io.File.separatorChar); String fullname = script_entry.getScriptPath() + pathedName + ".class"; File file = new File(fullname); - if (file != null) - { - if (file.exists()) - result = true; + if (file.isFile()) { + result = true; } + } return result; } // unloadClass() @@ -209,8 +202,6 @@ public class script_class_loader extends ClassLoader */ protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { -// System.out.println("script_class_loader loadClass " + name); - // filter out classes that will be loaded by the default loader int nameLength = name.length(); if ((nameLength > 5 && name.substring(0, 5).compareTo("java.") == 0) || @@ -218,14 +209,9 @@ public class script_class_loader extends ClassLoader (nameLength > 10 && name.substring(0, 10).compareTo("intuitive.") == 0) || defaultLoad.contains(name)) { -// System.out.println("****script_class_loader calling default loader**** class = " + name); Class cls = super.loadClass(name, resolve); if (myClass == null) myClass = cls; - if (name.equals("java.lang.Throwable")) - { - - } return cls; } @@ -262,13 +248,12 @@ public class script_class_loader extends ClassLoader */ protected Class findClass(String name) throws ClassNotFoundException { -// System.out.println("script_class_loader findClass " + name); if (myClass == null) { try { byte data[] = loadClassData(name); - myClass = defineClass(name, data, 0, data.length); + myClass = defineClass(name, data, 0, data.length); // we need to keep track of all the superclasses of this class, in case one of them is reloaded for (Class superClass = myClass.getSuperclass(); superClass != null; superClass = superClass.getSuperclass()) @@ -295,14 +280,13 @@ public class script_class_loader extends ClassLoader */ private byte[] loadClassData(String name) throws ClassNotFoundException { -// System.out.println("script_class_loader loadClassData enter: " + name); - byte[] data = null; // if the script name has '.' in it, convert them to '\' String pathedName = name.replace('.', java.io.File.separatorChar); String fullname = script_entry.getScriptPath() + pathedName + ".class"; - System.out.println("script_class_loader loadClassData " + fullname); + System.out.println("loadClassData " + fullname); + try { RandomAccessFile file = new RandomAccessFile(fullname, "r"); From e5eea503d82b17224c6fe25150ab75df3a1e86f3 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 04:26:03 +0000 Subject: [PATCH 2/7] some heavy cleanup on deltadictionary.java --- .../compiled/game/script/deltadictionary.java | 101 +----------------- 1 file changed, 3 insertions(+), 98 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/deltadictionary.java b/sku.0/sys.server/compiled/game/script/deltadictionary.java index b8f50fd31..117150580 100644 --- a/sku.0/sys.server/compiled/game/script/deltadictionary.java +++ b/sku.0/sys.server/compiled/game/script/deltadictionary.java @@ -68,104 +68,8 @@ public final class deltadictionary Thread.dumpStack(); return null; } - Object test = v.get(0); - if (test == null) - { - System.err.println("WARNING: deltadictionary.put passed vector with null data"); - Thread.dumpStack(); - return null; - } - if (test instanceof Integer) - { - int[] newValue = new int[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Integer)v.get(i)).intValue(); - value = newValue; - } - else if (test instanceof Long) - { - long[] newValue = new long[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Long)v.get(i)).longValue(); - value = newValue; - } - else if (test instanceof Float) - { - float[] newValue = new float[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Float)v.get(i)).floatValue(); - value = newValue; - } - else if (test instanceof Double) - { - double[] newValue = new double[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Double)v.get(i)).doubleValue(); - value = newValue; - } - else if (test instanceof Boolean) - { - boolean[] newValue = new boolean[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Boolean)v.get(i)).booleanValue(); - value = newValue; - } - else if (test instanceof Character) - { - char[] newValue = new char[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Character)v.get(i)).charValue(); - value = newValue; - } - else if (test instanceof Byte) - { - byte[] newValue = new byte[v.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Byte)v.get(i)).byteValue(); - value = newValue; - } - else if (test instanceof String) - { - String[] newValue = new String[v.size()]; - newValue = (String[])v.toArray(newValue); - value = newValue; - } - else if (test instanceof location) - { - location[] newValue = new location[v.size()]; - newValue = (location[])v.toArray(newValue); - value = newValue; - } - else if (test instanceof string_id) - { - string_id[] newValue = new string_id[v.size()]; - newValue = (string_id[])v.toArray(newValue); - value = newValue; - } - else if (test instanceof obj_id) - { - obj_id[] newValue = new obj_id[v.size()]; - newValue = (obj_id[])v.toArray(newValue); - value = newValue; - } - else if (test instanceof transform) - { - transform[] newValue = new transform[v.size()]; - newValue = (transform[])v.toArray(newValue); - value = newValue; - } - else if (test instanceof vector) - { - vector[] newValue = new vector[v.size()]; - newValue = (vector[])v.toArray(newValue); - value = newValue; - } - else - { - System.err.println("WARNING: deltadictionary.put passed unhandled vector data type " + test.getClass()); - Thread.dumpStack(); - return null; - } + + value = v.toArray(); } return currentValue.put(key, value); } // put(Object, Object) @@ -272,6 +176,7 @@ public final class deltadictionary /** * Gets a value from the dictionary. */ + //DA todo: this one and others like it may be a little stinky public Vector getResizeableIntArray(Object key) { Object value = currentValue.get(key); From e6a2197781c70ab38acee25881aee81e57af84df Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 04:38:27 +0000 Subject: [PATCH 3/7] dictionary and deltadictionary - one cleanup and one fix where i forgot to keep a null check --- .../compiled/game/script/deltadictionary.java | 7 ++ .../compiled/game/script/dictionary.java | 96 +------------------ 2 files changed, 9 insertions(+), 94 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/deltadictionary.java b/sku.0/sys.server/compiled/game/script/deltadictionary.java index 117150580..0f4175124 100644 --- a/sku.0/sys.server/compiled/game/script/deltadictionary.java +++ b/sku.0/sys.server/compiled/game/script/deltadictionary.java @@ -69,6 +69,13 @@ public final class deltadictionary return null; } + if (v.get(0) == null) + { + System.err.println("WARNING: deltadictionary.put passed vector with null data"); + Thread.dumpStack(); + return null; + } + value = v.toArray(); } return currentValue.put(key, value); diff --git a/sku.0/sys.server/compiled/game/script/dictionary.java b/sku.0/sys.server/compiled/game/script/dictionary.java index 74b8f012e..0a61c25f1 100755 --- a/sku.0/sys.server/compiled/game/script/dictionary.java +++ b/sku.0/sys.server/compiled/game/script/dictionary.java @@ -457,100 +457,8 @@ public class dictionary implements Serializable Thread.dumpStack(); return null; } - Object realValue = null; - if (test instanceof Integer) - { - int[] newValue = new int[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Integer)value.get(i)).intValue(); - realValue = newValue; - } - else if (test instanceof Long) - { - long[] newValue = new long[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Long)value.get(i)).longValue(); - realValue = newValue; - } - else if (test instanceof Float) - { - float[] newValue = new float[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Float)value.get(i)).floatValue(); - realValue = newValue; - } - else if (test instanceof Double) - { - double[] newValue = new double[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Double)value.get(i)).doubleValue(); - realValue = newValue; - } - else if (test instanceof Boolean) - { - boolean[] newValue = new boolean[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Boolean)value.get(i)).booleanValue(); - realValue = newValue; - } - else if (test instanceof Character) - { - char[] newValue = new char[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Character)value.get(i)).charValue(); - realValue = newValue; - } - else if (test instanceof Byte) - { - byte[] newValue = new byte[value.size()]; - for ( int i = 0; i < newValue.length; ++i ) - newValue[i] = ((Byte)value.get(i)).byteValue(); - realValue = newValue; - } - else if (test instanceof String) - { - String[] newValue = new String[value.size()]; - newValue = (String[])value.toArray(newValue); - realValue = newValue; - } - else if (test instanceof location) - { - location[] newValue = new location[value.size()]; - newValue = (location[])value.toArray(newValue); - realValue = newValue; - } - else if (test instanceof string_id) - { - string_id[] newValue = new string_id[value.size()]; - newValue = (string_id[])value.toArray(newValue); - realValue = newValue; - } - else if (test instanceof obj_id) - { - obj_id[] newValue = new obj_id[value.size()]; - newValue = (obj_id[])value.toArray(newValue); - realValue = newValue; - } - else if (test instanceof transform) - { - transform[] newValue = new transform[value.size()]; - newValue = (transform[])value.toArray(newValue); - realValue = newValue; - } - else if (test instanceof vector) - { - vector[] newValue = new vector[value.size()]; - newValue = (vector[])value.toArray(newValue); - realValue = newValue; - } - else - { - System.err.println("ERROR calling dictionary.put(Object, Vector): resizeable array value " + - "has unhandled vector data type " + test.getClass()); - Thread.dumpStack(); - return null; - } - return put(key, realValue); + + return put(key, value.toArray()); } // put(Object, Vector) /** From 1ca8cc2bb6dd0bef9853846f1bcf467a52f263f7 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 04:45:03 +0000 Subject: [PATCH 4/7] remove executable bits --- sku.0/sys.server/compiled/game/script/base_class.java | 0 sku.0/sys.server/compiled/game/script/base_script.java | 0 sku.0/sys.server/compiled/game/script/dictionary.java | 0 sku.0/sys.server/compiled/game/script/obj_id.java | 0 sku.0/sys.server/compiled/game/script/obj_var.java | 0 sku.0/sys.server/compiled/game/script/script_entry.java | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/base_class.java mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/base_script.java mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/dictionary.java mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/obj_id.java mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/obj_var.java mode change 100755 => 100644 sku.0/sys.server/compiled/game/script/script_entry.java diff --git a/sku.0/sys.server/compiled/game/script/base_class.java b/sku.0/sys.server/compiled/game/script/base_class.java old mode 100755 new mode 100644 diff --git a/sku.0/sys.server/compiled/game/script/base_script.java b/sku.0/sys.server/compiled/game/script/base_script.java old mode 100755 new mode 100644 diff --git a/sku.0/sys.server/compiled/game/script/dictionary.java b/sku.0/sys.server/compiled/game/script/dictionary.java old mode 100755 new mode 100644 diff --git a/sku.0/sys.server/compiled/game/script/obj_id.java b/sku.0/sys.server/compiled/game/script/obj_id.java old mode 100755 new mode 100644 diff --git a/sku.0/sys.server/compiled/game/script/obj_var.java b/sku.0/sys.server/compiled/game/script/obj_var.java old mode 100755 new mode 100644 diff --git a/sku.0/sys.server/compiled/game/script/script_entry.java b/sku.0/sys.server/compiled/game/script/script_entry.java old mode 100755 new mode 100644 From 108d5b779e7fb8489da2601d3d21c928d3349667 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 06:56:50 +0000 Subject: [PATCH 5/7] Revert "dictionary and deltadictionary - one cleanup and one fix where i forgot to keep a null check" This reverts commit e6a2197781c70ab38acee25881aee81e57af84df. --- .../compiled/game/script/deltadictionary.java | 7 -- .../compiled/game/script/dictionary.java | 96 ++++++++++++++++++- 2 files changed, 94 insertions(+), 9 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/deltadictionary.java b/sku.0/sys.server/compiled/game/script/deltadictionary.java index 0f4175124..117150580 100644 --- a/sku.0/sys.server/compiled/game/script/deltadictionary.java +++ b/sku.0/sys.server/compiled/game/script/deltadictionary.java @@ -69,13 +69,6 @@ public final class deltadictionary return null; } - if (v.get(0) == null) - { - System.err.println("WARNING: deltadictionary.put passed vector with null data"); - Thread.dumpStack(); - return null; - } - value = v.toArray(); } return currentValue.put(key, value); diff --git a/sku.0/sys.server/compiled/game/script/dictionary.java b/sku.0/sys.server/compiled/game/script/dictionary.java index 0a61c25f1..74b8f012e 100644 --- a/sku.0/sys.server/compiled/game/script/dictionary.java +++ b/sku.0/sys.server/compiled/game/script/dictionary.java @@ -457,8 +457,100 @@ public class dictionary implements Serializable Thread.dumpStack(); return null; } - - return put(key, value.toArray()); + Object realValue = null; + if (test instanceof Integer) + { + int[] newValue = new int[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Integer)value.get(i)).intValue(); + realValue = newValue; + } + else if (test instanceof Long) + { + long[] newValue = new long[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Long)value.get(i)).longValue(); + realValue = newValue; + } + else if (test instanceof Float) + { + float[] newValue = new float[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Float)value.get(i)).floatValue(); + realValue = newValue; + } + else if (test instanceof Double) + { + double[] newValue = new double[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Double)value.get(i)).doubleValue(); + realValue = newValue; + } + else if (test instanceof Boolean) + { + boolean[] newValue = new boolean[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Boolean)value.get(i)).booleanValue(); + realValue = newValue; + } + else if (test instanceof Character) + { + char[] newValue = new char[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Character)value.get(i)).charValue(); + realValue = newValue; + } + else if (test instanceof Byte) + { + byte[] newValue = new byte[value.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Byte)value.get(i)).byteValue(); + realValue = newValue; + } + else if (test instanceof String) + { + String[] newValue = new String[value.size()]; + newValue = (String[])value.toArray(newValue); + realValue = newValue; + } + else if (test instanceof location) + { + location[] newValue = new location[value.size()]; + newValue = (location[])value.toArray(newValue); + realValue = newValue; + } + else if (test instanceof string_id) + { + string_id[] newValue = new string_id[value.size()]; + newValue = (string_id[])value.toArray(newValue); + realValue = newValue; + } + else if (test instanceof obj_id) + { + obj_id[] newValue = new obj_id[value.size()]; + newValue = (obj_id[])value.toArray(newValue); + realValue = newValue; + } + else if (test instanceof transform) + { + transform[] newValue = new transform[value.size()]; + newValue = (transform[])value.toArray(newValue); + realValue = newValue; + } + else if (test instanceof vector) + { + vector[] newValue = new vector[value.size()]; + newValue = (vector[])value.toArray(newValue); + realValue = newValue; + } + else + { + System.err.println("ERROR calling dictionary.put(Object, Vector): resizeable array value " + + "has unhandled vector data type " + test.getClass()); + Thread.dumpStack(); + return null; + } + return put(key, realValue); } // put(Object, Vector) /** From f3c5bf803d82e0b0983b05dec710779d11401d83 Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 06:57:15 +0000 Subject: [PATCH 6/7] Revert "some heavy cleanup on deltadictionary.java" This reverts commit e5eea503d82b17224c6fe25150ab75df3a1e86f3. --- .../compiled/game/script/deltadictionary.java | 101 +++++++++++++++++- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/sku.0/sys.server/compiled/game/script/deltadictionary.java b/sku.0/sys.server/compiled/game/script/deltadictionary.java index 117150580..b8f50fd31 100644 --- a/sku.0/sys.server/compiled/game/script/deltadictionary.java +++ b/sku.0/sys.server/compiled/game/script/deltadictionary.java @@ -68,8 +68,104 @@ public final class deltadictionary Thread.dumpStack(); return null; } - - value = v.toArray(); + Object test = v.get(0); + if (test == null) + { + System.err.println("WARNING: deltadictionary.put passed vector with null data"); + Thread.dumpStack(); + return null; + } + if (test instanceof Integer) + { + int[] newValue = new int[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Integer)v.get(i)).intValue(); + value = newValue; + } + else if (test instanceof Long) + { + long[] newValue = new long[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Long)v.get(i)).longValue(); + value = newValue; + } + else if (test instanceof Float) + { + float[] newValue = new float[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Float)v.get(i)).floatValue(); + value = newValue; + } + else if (test instanceof Double) + { + double[] newValue = new double[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Double)v.get(i)).doubleValue(); + value = newValue; + } + else if (test instanceof Boolean) + { + boolean[] newValue = new boolean[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Boolean)v.get(i)).booleanValue(); + value = newValue; + } + else if (test instanceof Character) + { + char[] newValue = new char[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Character)v.get(i)).charValue(); + value = newValue; + } + else if (test instanceof Byte) + { + byte[] newValue = new byte[v.size()]; + for ( int i = 0; i < newValue.length; ++i ) + newValue[i] = ((Byte)v.get(i)).byteValue(); + value = newValue; + } + else if (test instanceof String) + { + String[] newValue = new String[v.size()]; + newValue = (String[])v.toArray(newValue); + value = newValue; + } + else if (test instanceof location) + { + location[] newValue = new location[v.size()]; + newValue = (location[])v.toArray(newValue); + value = newValue; + } + else if (test instanceof string_id) + { + string_id[] newValue = new string_id[v.size()]; + newValue = (string_id[])v.toArray(newValue); + value = newValue; + } + else if (test instanceof obj_id) + { + obj_id[] newValue = new obj_id[v.size()]; + newValue = (obj_id[])v.toArray(newValue); + value = newValue; + } + else if (test instanceof transform) + { + transform[] newValue = new transform[v.size()]; + newValue = (transform[])v.toArray(newValue); + value = newValue; + } + else if (test instanceof vector) + { + vector[] newValue = new vector[v.size()]; + newValue = (vector[])v.toArray(newValue); + value = newValue; + } + else + { + System.err.println("WARNING: deltadictionary.put passed unhandled vector data type " + test.getClass()); + Thread.dumpStack(); + return null; + } } return currentValue.put(key, value); } // put(Object, Object) @@ -176,7 +272,6 @@ public final class deltadictionary /** * Gets a value from the dictionary. */ - //DA todo: this one and others like it may be a little stinky public Vector getResizeableIntArray(Object key) { Object value = currentValue.get(key); From a6c6fa70d6bcdbeb841b9a53d6eb032c40224acf Mon Sep 17 00:00:00 2001 From: DarthArgus Date: Sat, 2 Apr 2016 16:11:46 +0000 Subject: [PATCH 7/7] check if file is null to avoid nullptr --- sku.0/sys.server/compiled/game/script/script_class_loader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sku.0/sys.server/compiled/game/script/script_class_loader.java b/sku.0/sys.server/compiled/game/script/script_class_loader.java index 70b734e88..9534f79a1 100644 --- a/sku.0/sys.server/compiled/game/script/script_class_loader.java +++ b/sku.0/sys.server/compiled/game/script/script_class_loader.java @@ -141,7 +141,7 @@ public class script_class_loader extends ClassLoader String pathedName = name.replace('.', java.io.File.separatorChar); String fullname = script_entry.getScriptPath() + pathedName + ".class"; File file = new File(fullname); - if (file.isFile()) { + if (file != null && file.isFile()) { result = true; }