Skip to content

Commit 80dfa69

Browse files
author
dlsmith
committed
Rolled back revision 3427, which changed the representation of types from Class<?> to java.lang.reflect.Type (a class introduced in Java 5.0).
git-svn-id: file:///tmp/test-svn/trunk@3798 fe72c1cf-3628-48e9-8b72-1c46755d3cff
1 parent 579a4d8 commit 80dfa69

34 files changed

+1180
-1158
lines changed

dynamicjava/src/koala/dynamicjava/classfile/JVMUtilities.java

Lines changed: 77 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,59 +116,102 @@ public abstract class JVMUtilities {
116116
stypes.put("void", "V");
117117
}
118118

119-
/** Returns the string that represents internally the given class. */
119+
/**
120+
* Returns the string that represents internally the given class
121+
*/
120122
public static String getName(Class<?> c) {
121123
String s = types.get(c);
122-
if (s != null) return s;
123-
return c.getName().replace('.', '/');
124+
if (s != null) {
125+
return s;
126+
} else {
127+
return c.getName().replace('.', '/');
128+
}
124129
}
125130

126-
/** Returns the string that represents internally the given class name. */
131+
/**
132+
* Returns the string that represents internally the given class name
133+
*/
127134
public static String getName(String c) {
128135
String s = stypes.get(c);
129-
if (s != null) return s;
130-
if (c.endsWith("[]")) {
131-
if (c.endsWith("[][]")) return "[" + getName(c.substring(0, c.length()-2));
132-
return "["+ getReturnTypeName(c.substring(0, c.length()-2));
133-
}
134-
return c.replace('.', '/'); // What if the array class has more than two dimensions?
136+
if (s != null) {
137+
return s;
138+
} else {
139+
if (c.endsWith("[]")) {
140+
if (c.endsWith("[][]")) {
141+
return "["+getName(c.substring(0, c.length()-2));
142+
} else {
143+
return "["+getReturnTypeName(c.substring(0, c.length()-2));
144+
}
145+
} else {
146+
return c.replace('.', '/');
147+
}
148+
}
135149
}
136150

137-
/** Returns the string that represents internally the given class */
151+
/**
152+
* Returns the string that represents internally the given class
153+
*/
138154
public static String getReturnTypeName(Class<?> c) {
139155
String s = types.get(c);
140-
if (s != null) return s;
141-
return ((c.isArray()) ? c.getName() : "L" + c.getName() + ";").replace('.', '/');
156+
if (s != null) {
157+
return s;
158+
} else {
159+
return ((c.isArray()) ?
160+
c.getName() : "L" + c.getName() + ";").replace('.', '/');
161+
}
142162
}
143163

144-
/** Returns the string that represents internally the given class name. */
164+
/**
165+
* Returns the string that represents internally the given class name
166+
*/
145167
public static String getReturnTypeName(String c) {
146168
String s = stypes.get(c);
147-
if (s != null) return s;
148-
if (c.endsWith("[]")) return "["+getReturnTypeName(c.substring(0, c.length()-2));
149-
return ((c.startsWith("[")) ? c : "L" + c + ";").replace('.', '/');
169+
if (s != null) {
170+
return s;
171+
} else {
172+
if (c.endsWith("[]")) {
173+
return "["+getReturnTypeName(c.substring(0, c.length()-2));
174+
} else {
175+
return ((c.startsWith("[")) ?
176+
c : "L" + c + ";").replace('.', '/');
177+
}
178+
}
150179
}
151180

152-
/** Returns the string that represents internally the given class. */
153-
public static String getParameterTypeName(Class c) { return getReturnTypeName(c); }
154-
181+
/**
182+
* Returns the string that represents internally the given class
183+
*/
184+
public static String getParameterTypeName(Class<?> c) {
185+
return getReturnTypeName(c);
186+
}
155187

156-
/** Returns the string that represents internally the given class name. */
157-
public static String getParameterTypeName(String c) { return getReturnTypeName(c); }
188+
/**
189+
* Returns the string that represents internally the given class name
190+
*/
191+
public static String getParameterTypeName(String c) {
192+
return getReturnTypeName(c);
193+
}
158194

159-
/** Creates a method descriptor
160-
* @param rt the return type name as returned by getReturnTypeName
161-
* @param pt the parameters type names as returned by getParameterTypeName
195+
/**
196+
* Creates a method descriptor
197+
* @param rt the return type name as returned by getReturnTypeName
198+
* @param pt the parameters type names as returned by getParameterTypeName
162199
*/
163-
public static String createMethodDescriptor(String rt, String[] pts) {
164-
if (pts != null) {
165-
StringBuffer result = new StringBuffer("(");
166-
for (String pt: pts) result.append(pt);
167-
return result.append(')').append(rt).toString(); // Note: append operation modifies the receiver!
168-
}
169-
return rt;
200+
public static String createMethodDescriptor(String rt, String[] pt) {
201+
if (pt != null) {
202+
String result = "(";
203+
for (int i = 0; i < pt.length; i++) {
204+
result += pt[i];
205+
}
206+
return result + ")" + rt;
207+
} else {
208+
return rt;
209+
}
170210
}
171211

172-
/** No need to create instances of this class */
173-
private JVMUtilities() { }
212+
/**
213+
* No need to create instances of this class
214+
*/
215+
private JVMUtilities() {
216+
}
174217
}

dynamicjava/src/koala/dynamicjava/classinfo/ClassInfoUtilities.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,21 +236,22 @@ public static MethodInfo lookupMethod(ClassInfo cl, String name, ClassInfo[] ac)
236236
* @param cl the inner class
237237
* @param name the name of the method
238238
* @param ac the arguments classes (possibly not the exact declaring classes)
239-
* @pre cl is not null
240239
*/
241240
public static MethodInfo lookupOuterMethod(ClassInfo cl, String name, ClassInfo[] ac)
242241
throws NoSuchMethodException {
243-
244242
boolean sc = Modifier.isStatic(cl.getModifiers());
245-
ClassInfo c = cl.getDeclaringClass();
246-
do {
243+
ClassInfo c = (cl != null) ? cl.getDeclaringClass() : null;
244+
while (c != null) {
247245
sc |= Modifier.isStatic(c.getModifiers());
248246
try {
249247
MethodInfo m = lookupMethod(c, name, ac);
250-
if (!sc || Modifier.isStatic(m.getModifiers())) return m;
251-
} catch (NoSuchMethodException e) { /* This point is reachable! */ }
248+
if (!sc || Modifier.isStatic(m.getModifiers())) {
249+
return m;
250+
}
251+
} catch (NoSuchMethodException e) {
252+
}
252253
c = c.getDeclaringClass();
253-
} while (c != null);
254+
}
254255
throw new NoSuchMethodException(name);
255256
}
256257

dynamicjava/src/koala/dynamicjava/gui/Main.java

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public class Main extends JFrame implements ActionMap {
5353
* The entry point of the program
5454
*/
5555
public static void main(String[] args) {
56-
new Main().setVisible(true);
56+
new Main().show();
5757
}
5858

5959
// The action names
@@ -70,7 +70,7 @@ public static void main(String[] args) {
7070
public final static String OPTIONS_ACTION = "OptionsAction";
7171
public final static String EVAL_ACTION = "EvalAction";
7272
public final static String EVAL_S_ACTION = "EvalSAction";
73-
// public final static String STOP_ACTION = "StopAction";
73+
public final static String STOP_ACTION = "StopAction";
7474
public final static String REINIT_ACTION = "ReinitAction";
7575
public final static String ABOUT_ACTION = "AboutAction";
7676

@@ -144,10 +144,10 @@ public static void main(String[] args) {
144144
*/
145145
protected EvalSelectionAction evalSelection = new EvalSelectionAction();
146146

147-
// /**
148-
// * The stop action
149-
// */
150-
// protected StopAction stopAction = new StopAction();
147+
/**
148+
* The stop action
149+
*/
150+
protected StopAction stopAction = new StopAction();
151151

152152
/**
153153
* The current interpreter thread
@@ -241,7 +241,7 @@ public void windowClosing(WindowEvent e) {
241241
listeners.put(OPTIONS_ACTION, new OptionsAction());
242242
listeners.put(EVAL_ACTION, evalAction);
243243
listeners.put(EVAL_S_ACTION, evalSelection);
244-
// listeners.put(STOP_ACTION, stopAction);
244+
listeners.put(STOP_ACTION, stopAction);
245245
listeners.put(REINIT_ACTION, new ReinitAction());
246246
listeners.put(ABOUT_ACTION, new AboutAction());
247247

@@ -604,7 +604,7 @@ public void actionPerformed(ActionEvent e) {
604604
Dimension od = options.getSize();
605605
options.setLocation(fr.x + (fr.width - od.width) / 2,
606606
fr.y + (fr.height - od.height) / 2);
607-
options.setVisible(true);
607+
options.show();
608608
}
609609
}
610610

@@ -653,7 +653,7 @@ public void run() {
653653
System.setErr(err);
654654
try {
655655
isRunning = true;
656-
// stopAction.update();
656+
stopAction.update();
657657
evalAction.update();
658658
evalSelection.update();
659659
output.append("==> " + interpreter.interpret(reader, "buffer") + "\n");
@@ -668,7 +668,7 @@ public void run() {
668668
System.setErr(olderr);
669669
}
670670
isRunning = false;
671-
// stopAction.update();
671+
stopAction.update();
672672
evalAction.update();
673673
evalSelection.update();
674674

@@ -707,35 +707,35 @@ protected void update() {
707707
}
708708
}
709709

710-
// /**
711-
// * To stop the interpreter thread
712-
// */
713-
// protected class StopAction extends AbstractAction
714-
// implements JComponentModifier {
715-
// java.util.List<JComponent> components = new LinkedList<JComponent>();
716-
//
717-
// public void actionPerformed(ActionEvent ev) {
718-
// thread.stop();
719-
// isRunning = false;
720-
// update();
721-
// evalAction.update();
722-
// evalSelection.update();
723-
// status.setMessage("Status.evaluation.stopped");
724-
// }
725-
//
726-
// public void addJComponent(JComponent c) {
727-
// components.add(c);
728-
// c.setEnabled(false);
729-
// }
730-
//
731-
// protected void update() {
732-
// Iterator<JComponent> it = components.iterator();
733-
// while (it.hasNext()) {
734-
// it.next().setEnabled(isRunning);
735-
// }
736-
// }
737-
// }
738-
//
710+
/**
711+
* To stop the interpreter thread
712+
*/
713+
protected class StopAction extends AbstractAction
714+
implements JComponentModifier {
715+
java.util.List<JComponent> components = new LinkedList<JComponent>();
716+
717+
public void actionPerformed(ActionEvent ev) {
718+
thread.stop();
719+
isRunning = false;
720+
update();
721+
evalAction.update();
722+
evalSelection.update();
723+
status.setMessage("Status.evaluation.stopped");
724+
}
725+
726+
public void addJComponent(JComponent c) {
727+
components.add(c);
728+
c.setEnabled(false);
729+
}
730+
731+
protected void update() {
732+
Iterator<JComponent> it = components.iterator();
733+
while (it.hasNext()) {
734+
it.next().setEnabled(isRunning);
735+
}
736+
}
737+
}
738+
739739
/**
740740
* Reinitializes the interpreter
741741
*/

dynamicjava/src/koala/dynamicjava/gui/OptionsDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ public void actionPerformed(ActionEvent e) {
742742
Dimension ud = urlChooser.getSize();
743743
urlChooser.setLocation(fr.x + (fr.width - ud.width) / 2,
744744
fr.y + (fr.height - ud.height) / 2);
745-
urlChooser.setVisible(true);
745+
urlChooser.show();
746746
}
747747
}
748748

0 commit comments

Comments
 (0)