jrubyfx-fxmlloader 0.2-java → 0.3-java

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,31 +24,6 @@
24
24
  */
25
25
  =end
26
26
 
27
- #package com.sun.javafx.fxml;
28
- #
29
- #import java.lang.reflect.InvocationTargetException;
30
- #import java.lang.reflect.Method;
31
- #import java.lang.reflect.Modifier;
32
- #import java.lang.reflect.ParameterizedType;
33
- #import java.lang.reflect.Type;
34
- #import java.lang.reflect.TypeVariable;
35
- #import java.math.BigDecimal;
36
- #import java.math.BigInteger;
37
- #import java.util.AbstractMap;
38
- #import java.util.Arrays;
39
- #import java.util.HashMap;
40
- #import java.util.LinkedList;
41
- #import java.util.List;
42
- #import java.util.Map;
43
- #import java.util.Set;
44
- #
45
- #import java.lang.reflect.*;
46
- #
47
- #import javafx.@beans.value.ObservableValue;
48
- #import sun.reflect.misc.FieldUtil;
49
- #import sun.reflect.misc.MethodUtil;
50
- #import sun.reflect.misc.ReflectUtil;
51
-
52
27
  #/**
53
28
  # * Exposes Java Bean properties of an object via the {@link Mapend interface.
54
29
  # * A call to {@link Map#get(Object)end invokes the getter for the corresponding
@@ -93,9 +68,8 @@ class RubyObjectWrapperBeanAdapter
93
68
  def [](key)
94
69
  return @bean.send("get#{key[0].upcase}#{key[1..-1]}")
95
70
  end
96
-
71
+
97
72
  def []=(key, value)
98
- dputs "calling setterrorab"
99
73
  if (key == nil)
100
74
  raise "NULL PTR"
101
75
  end
@@ -111,14 +85,14 @@ class RubyObjectWrapperBeanAdapter
111
85
  end
112
86
  @bean.methods.include? "set#{key[0].upcase}#{key[1..-1]}"
113
87
  end
114
-
88
+
115
89
  def getType(key)
116
90
  if (key == nil)
117
91
  raise ArgumentError.new();
118
92
  end
119
93
  @bean.send(key + "GetType")
120
94
  end
121
-
95
+
122
96
  def getPropertyModel(key)
123
97
  if (key == nil)
124
98
  raise ArgumentError.new();
@@ -32,10 +32,8 @@
32
32
  # * corresponding property model.
33
33
  # */
34
34
  class RubyWrapperBeanAdapter
35
- # private final Object @bean;
36
35
 
37
-
38
- @@globalMethodCache = {}
36
+ @@method_cache = {}
39
37
 
40
38
  GET_PREFIX = "get"
41
39
  IS_PREFIX = "is"
@@ -44,337 +42,235 @@ class RubyWrapperBeanAdapter
44
42
 
45
43
  VALUE_OF_METHOD_NAME = "valueOf"
46
44
 
47
- # static
48
- # contextClassLoader = Thread.currentThread().getContextClassLoader();
49
- #
50
- # if (contextClassLoader == nil)
51
- # raise ArgumentError.new();
52
- # end
53
- # end
45
+ OBJECT_PUBLIC_METHODS = Object.new.public_methods
54
46
 
55
- #Creates a Bean.new adapter.
56
- #
57
47
  #@param @bean
58
48
  #The Bean object to wrap.
59
49
  def initialize(bean)
60
- @bean = bean;
61
-
50
+ @bean = bean
62
51
  type = @bean.java_class
63
-
64
- while (type != Java.java.lang.Object.java_class && !@@globalMethodCache.has_key?(type))
65
- @@globalMethodCache[type] = getClassMethodCache(type)
66
- type = type.superclass();
67
- end
52
+ javas = []
53
+ while type != java.lang.Object.java_class && !@@method_cache.has_key?(type)
54
+ javas += build_cache_for(type)
55
+ type = type.superclass
56
+ end
57
+ # class_methods = {}
58
+ # (@bean.public_methods - OBJECT_PUBLIC_METHODS - javas.map{|x|x.name.to_sym}).each do |method_name|
59
+ # puts "ruby method: #{method_name}"
60
+ # name = method_name.to_s
61
+ # unless class_methods.has_key? name
62
+ # class_methods[name] = []
63
+ # else
64
+ # class_methods[name]
65
+ # end << method_name.to_sym
66
+ # end
67
+ # @@method_cache[@bean.class] =
68
68
  end
69
69
 
70
- def getClassMethodCache(type)
71
- classMethodCache = {}
70
+ def build_cache_for(type)
71
+ class_methods = {}
72
72
 
73
- ReflectUtil.checkPackageAccess(type);
74
- declaredMethods = type.declared_instance_methods();
75
- declaredMethods.each do |method|
76
- modifiers = method.modifiers();
77
-
78
- if (Modifier.public?(modifiers) && !Modifier.static?(modifiers))
79
- name = method.name();
80
- namedMethods = classMethodCache[name]
81
-
82
- if (namedMethods == nil)
83
- namedMethods = []
84
- classMethodCache[name] = namedMethods
85
- end
73
+ ReflectUtil.checkPackageAccess(type) # TODO: do I want this ?
86
74
 
87
- namedMethods << (method)
75
+ java_methods = type.declared_instance_methods.each do |method|
76
+ modifiers = method.modifiers
77
+ if Modifier.public?(modifiers) && !Modifier.static?(modifiers)
78
+ name = method.name
79
+ unless class_methods.has_key? name
80
+ class_methods[name] = []
81
+ else
82
+ class_methods[name]
83
+ end << method
88
84
  end
89
85
  end
90
86
 
91
- return classMethodCache;
92
- end
93
-
94
- # /**
95
- # * Returns the Bean object this adapter wraps.
96
- # *
97
- # * @return
98
- # * The Bean object, or <tt>nil</tt> if no Bean has been set.
99
- # */
100
- def getBean()
101
- return @bean;
87
+ @@method_cache[type] = class_methods
88
+ return java_methods
102
89
  end
103
90
 
104
- def getMethod(name, *parameterTypes)
105
- type = @bean.java_class();
106
-
107
- method = nil;
108
- while (type != Java::java.lang.Object.java_class)
109
- classMethodCache = @@globalMethodCache[(type)] || {}
110
-
111
- namedMethods = classMethodCache[name]
112
- if (namedMethods != nil)
113
- for namedMethod in namedMethods
114
- if (namedMethod.name() == (name) && namedMethod.parameter_types() == parameterTypes)
115
- method = namedMethod;
116
- break;
117
- end
91
+ def getMethod(name, *parameter_types)
92
+ type = @bean.java_class
93
+ while type != java.lang.Object.java_class
94
+ if methods = (@@method_cache[type] || {})[name]
95
+ methods.each do |method|
96
+ return method if method.name == name && method.parameter_types == parameter_types
118
97
  end
119
98
  end
120
-
121
- if (method != nil)
122
- break;
123
- end
124
- type = type.superclass();
99
+ type = type.superclass
125
100
  end
126
-
127
- return method;
101
+ return nil
128
102
  end
129
103
 
130
- def getGetterMethod( key)
131
- getterMethod = getMethod(getMethodName(GET_PREFIX, key));
132
-
133
- if (getterMethod == nil)
134
- getterMethod = getMethod(getMethodName(IS_PREFIX, key));
135
- end
136
-
137
- return getterMethod;
104
+ def getter(key)
105
+ capital = camelize(key)
106
+ return getMethod(GET_PREFIX + capital) if @bean.respond_to?(GET_PREFIX + capital)
107
+ return getMethod(IS_PREFIX + capital)
138
108
  end
139
109
 
140
- def getSetterMethod( key)
141
- type = getType(key);
142
-
143
- if (type == nil)
144
- raise UnsupportedOperationException.new("Cannot determine type for property.");
145
- end
110
+ def setter(key)
111
+ raise java.lang.UnsupportedOperationException.new("Cannot determine type for property #{key}.") unless type = getType(key)
112
+ return getMethod(method_name(SET_PREFIX, key), type)
113
+ end
146
114
 
147
- return getMethod(getMethodName(SET_PREFIX, key), type)
115
+ def method_name(prefix, key)
116
+ return prefix + camelize(key)
148
117
  end
149
118
 
150
- def getMethodName(prefix, key)
151
- return prefix + key[0].upcase + key[1..-1];
119
+ def camelize(key)
120
+ key[0].upcase + key[1..-1]
152
121
  end
153
122
 
154
123
  def [](key)
155
124
  key = key.to_s
156
- getterMethod = key.end_with?(PROPERTY_SUFFIX) ? getMethod(key) : getGetterMethod(key);
157
-
158
- value = nil
159
- if (getterMethod != nil)
160
- begin
161
- value = getterMethod.invoke @bean
162
- rescue IllegalAccessException => exception
163
- raise RuntimeException.new(exception);
164
- rescue InvocationTargetException => exception
165
- raise RuntimeException.new(exception);
125
+ begin
126
+ unless key.end_with?(PROPERTY_SUFFIX)
127
+ camel = camelize(key)
128
+ unless !@bean.respond_to?(GET_PREFIX + camel) and @bean.respond_to?(IS_PREFIX + camel)
129
+ @bean.send(GET_PREFIX + camel)
130
+ else
131
+ @bean.send(IS_PREFIX + camel)
132
+ end
133
+ else
134
+ @bean.send key
166
135
  end
167
- else
168
- value = nil;
136
+ rescue NoMethodError => nme
137
+ raise unless nme.name.to_s.end_with?(key)
138
+ puts "failing on #{key}"
139
+ # p @bean
140
+ # p @bean.class
141
+ # puts caller
142
+ nil
169
143
  end
170
-
171
- return value;
172
144
  end
173
145
 
174
- # /**
175
- # * Invokes a setter method for the given property. The
176
- # * {@link #coerce(Object, Class)end method is used as needed to attempt to
177
- # * convert a given value to the property type, as defined by the return
178
- # * value of the getter method.
179
- # *
180
- # * @param key
181
- # * The property name.
182
- # *
183
- # * @param value
184
- # * The property.new value.
185
- # *
186
- # * @return
187
- # * Returns <tt>nil</tt>, since returning the previous value would require
188
- # * an unnecessary call to the getter method.
189
- # *
190
- # * @throws PropertyNotFoundException
191
- # * If the given property does not exist or is read-only.
192
- # */
193
- # @Override
194
146
  def []=(key, value)
195
- dputs "calling setter"
196
- if (key == nil)
197
- raise "NULL PTR"
198
- end
147
+ raise "NULL PTR" unless key
199
148
 
200
- setterMethod = getSetterMethod(key);
149
+ setter = method_name(SET_PREFIX, key)
201
150
 
202
- if (setterMethod == nil)
203
- dputs caller
204
- dputs "error in []=!"
205
- dp key, value, @bean
206
- raise PropertyNotFoundException.new("Property \"" + key + "\" does not exist" + " or is read-only.");
207
- end
208
- begin
209
- ty = getType(key)
210
- co = coerce(value, ty)
211
- setterMethod.invoke(@bean, co );
212
- rescue IllegalAccessException => exception
213
- dp "issues1"
214
- dp exception
215
- raise "RuntimeException.new(exception);"
216
- rescue InvocationTargetException => exception
217
- dp "issues2"
218
- dp exception
219
- raise R"untimeException.new(exception);"
220
- end
221
- dputs "eone"
222
- return nil;
223
- end
224
-
225
- # /**
226
- # * Verifies the existence of a property.
227
- # *
228
- # * @param key
229
- # * The property name.
230
- # *
231
- # * @return
232
- # * <tt>true</tt> if the property exists; <tt>false</tt>, otherwise.
233
- # */
234
- # @Override
235
- def has_key?( key)
236
- if (key == nil)
237
- raise "NULL PTR"
151
+ raise "Property \"#{key}\" does not exist or is read-only." unless @bean.respond_to? setter
152
+ ty = getType(key)
153
+ co = coerce(value, ty)
154
+ coi = RubyWrapperBeanAdapter.jit_export(co, value, ty, setter(key))
155
+ rputs @bean, "#{setter}(#{coi})"
156
+ if coi.start_with?("*[") # cheap way to not compute it twice :D
157
+ @bean.send(setter, *co)
158
+ else
159
+ @bean.send(setter, co)
238
160
  end
239
-
240
- return getType(key.to_s) != nil;
161
+ co
241
162
  end
242
163
 
243
- def entrySet()
244
- raise UnsupportedOperationException.new();
164
+ def has_key?(key)
165
+ raise "NULL PTR" unless key
166
+ getType(key.to_s)
245
167
  end
246
168
 
247
- # /**
248
- # * Tests the mutability of a property.
249
- # *
250
- # * @param key
251
- # * The property name.
252
- # *
253
- # * @return
254
- # * <tt>true</tt> if the property is read-only; <tt>false</tt>, otherwise.
255
- # */
256
169
  def read_only?(key)
257
- if (key == nil)
258
- raise "NULL PTR"
259
- end
260
- dputs "checking for readonly-ness of #{key}:"
261
- dp getSetterMethod(key)
262
- return getSetterMethod(key) == nil;
170
+ setter(key) == nil
263
171
  end
264
172
 
265
- # /**
266
- # * Returns the property model for the given property.
267
- # *
268
- # * @param key
269
- # * The property name.
270
- # *
271
- # * @return
272
- # * The named property model, or <tt>nil</tt> if no such property exists.
273
- # */
274
- # @SuppressWarnings("unchecked")
275
- def getPropertyModel( key)
276
- if (key == nil)
277
- raise ArgumentError.new();
278
- end
279
-
280
- return self[key + PROPERTY_SUFFIX]
173
+ def getPropertyModel(key)
174
+ raise ArgumentError.new unless key
175
+ self[key + PROPERTY_SUFFIX]
281
176
  end
282
177
 
283
- # /**
284
- # * Returns the type of a property.
285
- # *
286
- # * @param key
287
- # * The property name.
288
- # */
289
178
  def getType(key)
290
- if (key == nil)
291
- raise ArgumentError.new();
179
+ raise ArgumentError.new unless key
180
+ if @bean.respond_to? "#{key}GetType" # ruby type support ;-D
181
+ @bean.send("#{key}GetType")
182
+ else
183
+ getter = getter(key)
184
+ getter && getter.return_type
292
185
  end
293
-
294
- getterMethod = getGetterMethod(key);
295
-
296
- return (getterMethod == nil) ? nil : getterMethod.return_type();
297
186
  end
298
187
 
299
- # /**
300
- # * Returns the generic type of a property.
301
- # *
302
- # * @param key
303
- # * The property name.
304
- # */
305
- def getGenericType(key)
306
- if (key == nil)
307
- raise ArgumentError.new();
308
- end
309
-
310
- getterMethod = getGetterMethod(key);
311
- dputs "GOt getter method for #{key}"
312
- dp getterMethod
313
- dputs getterMethod
314
-
315
- return (getterMethod == nil) ? nil : getterMethod.return_type
316
- end
188
+ alias :getGenericType :getType
317
189
 
318
190
  def coerce(value, type)
319
191
  RubyWrapperBeanAdapter.coerce(value, type)
320
192
  end
321
- # /**
322
- # * Coerces a value to a given type.
323
- # *
324
- # * @param value
325
- # * @param type
326
- # *
327
- # * @return
328
- # * The coerced value.
329
- # */
330
- # @SuppressWarnings("unchecked")
331
- def self.coerce( value, type)
332
- dputs "coercing..."
333
- if (type == nil)
334
- dputs "WHAT!"
335
- raise "ArgumentError.new();"
336
- end
337
- if (value.class == Java::JavaObject)
338
- dputs "de-objectifying it!!!!"
339
- dp value.class
340
- dp value.java_class
341
- dp value.to_java
342
- value = value.to_java
343
- end
344
193
 
345
- coercedValue = nil;
346
- if (value == nil)
347
- # Null values can only be coerced to nil
348
- coercedValue = nil;
349
- elsif (value.is_a?(EventHandlerWrapper) && type == Java.javafx.event.EventHandler.java_class) || (value.respond_to?(:java_class) && !value.is_a?(EventHandlerWrapper) && type.assignable_from?(value.java_class))
350
- # Value doesn't require coercion
351
- coercedValue = value;
352
- elsif !value.respond_to?(:java_class) && !type.enum?
353
- # its a ruby value
194
+ def self.jit_export(co, value, ty, setter, ignore=nil)
195
+ coi = co.inspect
196
+ if co.is_a? Java::JavaLang::Enum
197
+ coi = "Java::#{co.java_class.name.gsub(/[\$\.]/, "::")}::#{co.to_s}"
198
+ elsif co.is_a? EventHandlerWrapper
199
+ coi = "EventHandlerWrapper.new(__local_fxml_controller, #{co.funcName.inspect})"
200
+ elsif co.is_a? ScriptEventHandler
201
+ coi = "ScriptEventHandler.new(#{co.script.inspect}, __local_sem_lang_inst_#{rget_sem(co.scriptEngine)})"
202
+ elsif tmp = rget(value)
203
+ coi = tmp
204
+ elsif co.is_a? Java::javafx.scene.paint.Paint
205
+ coi = "RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty.ruby_class}.java_class)"
206
+ elsif setter.respond_to? :varargs? and setter.varargs?
207
+ coi = "*#{coi}"
208
+ elsif coi.start_with? "#<"
209
+ # puts "ignoring #{setting}(#{coi})
210
+ # How about #{setting}(RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty})) ?#
211
+
212
+ # "
213
+ coi = "RubyWrapperBeanAdapter.coerce(#{value.inspect}, #{ty.ruby_class}.java_class)"
214
+ end
215
+ return coi
216
+ end
217
+
218
+ @@mapper = nil
219
+ def self.mapper
220
+ unless @@mapper
354
221
  dir = ->(x){x}
355
222
  to_x = ->(x){->(o){o.send(x)}}
356
223
  to_dbl = ->(x){java.lang.Double.valueOf(x.to_s)}
357
224
  to_bool = ->(x){java.lang.Boolean.valueOf(x.to_s)}
358
- value_of = ->(x){type.ruby_class.valueOf(x.to_s)}
225
+ value_of = ->(x, type){type.ruby_class.valueOf(x.to_s)}
359
226
  # TODO: Java::double[].java_class.component_type
360
- mapper = {
227
+ @@mapper = {
361
228
  [String, java.lang.String.java_class] => dir,
362
229
  [Fixnum, java.lang.Integer.java_class] => dir,
363
230
  [Float, java.lang.Double.java_class] => dir,
364
231
  [Float, Java::double.java_class] => dir,
232
+ [FalseClass, Java::boolean.java_class] => dir,
233
+ [TrueClass, Java::boolean.java_class] => dir,
365
234
  [String, Java::double.java_class] => to_dbl,
366
235
  [String, java.lang.Double.java_class] => to_dbl,
367
236
  [String, Java::int.java_class] => to_x.call(:to_i),
368
237
  [String,java.lang.Integer.java_class] => to_x.call(:to_i),
369
238
  [String, Java::boolean.java_class] => to_bool,
370
239
  [String, Java::javafx.scene.paint.Paint.java_class] => value_of,
371
- [String, Java::java.lang.Object.java_class] => ->(x){x},
240
+ [String, Java::javafx.scene.paint.Color.java_class] => value_of,
241
+ [String, Java::java.lang.Object.java_class] => dir,
372
242
  [String, Java::double[].java_class] => ->(x){x.split(/[, ]+/).map(&:to_f)}
373
243
  }
244
+ end
245
+ @@mapper
246
+ end
247
+
248
+ def self.coerce( value, type)
249
+ if (type == nil)
250
+ raise "ArgumentError.new();"
251
+ end
252
+ if (value.class == Java::JavaObject)
253
+ value = value.to_java
254
+ end
255
+
256
+ coercedValue = nil;
257
+ if (value == nil)
258
+ # Null values can only be coerced to nil
259
+ coercedValue = nil;
260
+ elsif type == java.lang.Object.java_class || (value.is_a?(EventHandlerWrapper) && type == Java.javafx.event.EventHandler.java_class) || (value.respond_to?(:java_class) && !value.is_a?(EventHandlerWrapper) && type.assignable_from?(value.java_class))
261
+ # Value doesn't require coercion
262
+ coercedValue = value;
263
+ elsif !value.respond_to?(:java_class) && !type.enum?
264
+ # its a ruby value
265
+
374
266
  if mapper[[value.class, type]]
375
- coercedValue = mapper[[value.class, type]].call(value)
267
+ coercedValue = mapper[[value.class, type]]
268
+ if coercedValue.arity == 1
269
+ coercedValue = coercedValue.call(value)
270
+ else
271
+ coercedValue = coercedValue.call(value, type)
272
+ end
376
273
  else
377
- dputs "!! Non-normal RUBY coerce (#{value}, #{type}) (#{value.inspect}, [#{value.class}, #{type.inspect}])"
378
274
  raise "Unknown Coercion map: (#{value}, #{type}) (#{value.inspect}, [#{value.class}, #{type.inspect}]; Please file a bug on this."
379
275
  end
380
276
  # Ruby String :D
@@ -390,122 +286,8 @@ class RubyWrapperBeanAdapter
390
286
  dputs "COnverting url to string"
391
287
  coercedValue = value.to_s
392
288
  else
393
- dputs "!! Non-normal coerce (#{value}, #{type}) (#{value.inspect}, #{type.inspect})"
394
- if (type == java.lang.Boolean.java_class || type == Boolean.TYPE)
395
- coercedValue = Boolean.valueOf(value.toString());
396
- elsif (type == Character.java_class || type == Character.TYPE)
397
- coercedValue = value.toString().charAt(0);
398
- elsif (type == Byte.java_class || type == Byte.TYPE)
399
- if (value.is_a? Number)
400
- coercedValue = (value).byteValue();
401
- else
402
- coercedValue = Byte.valueOf(value.toString());
403
- end
404
- elsif (type == Short.java_class || type == Short.TYPE)
405
- if (value.is_a? Number)
406
- coercedValue = (value).shortValue();
407
- else
408
- coercedValue = Short.valueOf(value.toString());
409
- end
410
- elsif (type == Integer.java_class || type == Integer.TYPE)
411
- if (value.is_a? Number)
412
- coercedValue = (value).intValue();
413
- else
414
- coercedValue = Integer.valueOf(value.toString());
415
- end
416
- elsif (type == Long.java_class || type == Long.TYPE)
417
- if (value.is_a? Number)
418
- coercedValue = (value).longValue();
419
- else
420
- coercedValue = Long.valueOf(value.toString());
421
- end
422
- elsif (type == BigInteger.java_class)
423
- if (value.is_a? Number)
424
- coercedValue = BigInteger.valueOf((value).longValue());
425
- else
426
- coercedValue = BigInteger.new(value.toString());
427
- end
428
- elsif (type == Float.java_class || type == Float.TYPE)
429
- if (value.is_a? Number)
430
- coercedValue = (value).floatValue();
431
- else
432
- coercedValue = Float.valueOf(value.toString());
433
- end
434
- elsif (type == Double.java_class || type == Double.TYPE)
435
- if (value.is_a? Number)
436
- coercedValue = (value).doubleValue();
437
- else
438
- coercedValue = Double.valueOf(value.toString());
439
- end
440
- elsif (type == Number.java_class)
441
- number = value.toString();
442
- if (number.contains("."))
443
- coercedValue = Double.valueOf(number);
444
- else
445
- coercedValue = Long.valueOf(number);
446
- end
447
- elsif (type == BigDecimal.java_class)
448
- if (value.is_a? Number)
449
- coercedValue = BigDecimal.valueOf((value).doubleValue());
450
- else
451
- coercedValue = BigDecimal.new(value.toString());
452
- end
453
- elsif (type == Class.java_class)
454
- begin
455
- ReflectUtil.checkPackageAccess(value.toString());
456
- coercedValue = Class.forName(
457
- value.to_s,
458
- false,
459
- JRuby.runtime.get_class_loader);
460
- rescue ClassNotFoundException => exception
461
- raise Exception.new(exception);
462
- end
463
- else
464
- dputs "elsee"
465
- valueType = value.java_class();
466
- valueOfMethod = nil;
467
-
468
- while (valueOfMethod == nil && valueType != nil)
469
- begin
470
- dputs "checking access"
471
- ReflectUtil.checkPackageAccess(type);
472
- valueOfMethod = type.declared_method(VALUE_OF_METHOD_NAME, valueType);
473
- rescue NoSuchMethodException => exception
474
- # No-op
475
- end
476
-
477
- if (valueOfMethod == nil)
478
- valueType = valueType.superclass();
479
- end
480
- end
481
-
482
- if (valueOfMethod == nil)
483
- raise IllegalArgumentException.new("Unable to coerce " + value + " to " + type + ".");
484
- end
485
-
486
- if type.isEnum() && value.is_a?(String) && value[0] == value[0].downcase
487
- value = RubyWrapperBeansAdapter.toUpcase value;
488
- end
489
-
490
- begin
491
- coercedValue = MethodUtil.invoke(valueOfMethod, nil, [ value ]);
492
- rescue IllegalAccessException => exception
493
- dputs "EAI1"
494
- dp exception
495
- raise "RuntimeException.new(exception);"
496
- rescue InvocationTargetException => exception
497
- dputs "ETI1"
498
- dp exception
499
- raise "RuntimeException.new(exception);"
500
- rescue SecurityException => exception
501
- dputs "SE1"
502
- dp exception
503
- raise "RuntimeException.new(exception);"
504
- end
505
- end
289
+ raise "!! Non-normal coerce (#{value}, #{type}) (#{value.inspect}, #{type.inspect})"
506
290
  end
507
- dputs "Coerced #{value.class} into a #{coercedValue.class} for #{type}"
508
- dp value, coercedValue
509
291
  return coercedValue;
510
292
  end
511
293
 
@@ -574,7 +356,6 @@ class RubyWrapperBeanAdapter
574
356
  elsif target.is_a? String
575
357
  targetType = java.lang.String.java_class
576
358
  else
577
- dp target, sourceType, key, value
578
359
  raise "Shoots!"
579
360
  end
580
361
 
@@ -587,7 +368,6 @@ class RubyWrapperBeanAdapter
587
368
  elsif value.is_a? String
588
369
  valueClass = java.lang.String.java_class
589
370
  else
590
- dp target, sourceType, key, value
591
371
  raise "Shoots TWICE!"
592
372
  end
593
373
  setterMethod = getStaticSetterMethod(sourceType, key, valueClass, targetType);
@@ -609,6 +389,7 @@ class RubyWrapperBeanAdapter
609
389
 
610
390
  # Invoke the setter
611
391
  begin
392
+ rputs target, "#{sourceType.ruby_class.inspect}.set#{key[0].upcase}#{key[1..-1]}(self, #{jit_export(value, value, targetType, key, "#{sourceType.ruby_class.inspect}.#{key}=")})"
612
393
  getStaticSetterMethod(sourceType, key, valueClass, targetType, true).call(target.java_object, value);
613
394
  rescue InvocationTargetException => exception
614
395
  raise "RuntimeException.new(exception);"
@@ -681,8 +462,6 @@ class RubyWrapperBeanAdapter
681
462
  if (itemType.is_a? ParameterizedType)
682
463
  itemType = (itemType).getRawType();
683
464
  end
684
- dputs "Listem item type is for "
685
- dp listType, itemType
686
465
  return itemType;
687
466
  end
688
467
 
@@ -710,41 +489,26 @@ class RubyWrapperBeanAdapter
710
489
  itemType = nil;
711
490
 
712
491
  parentType = listType;
713
- dputs "searching for generic #{listType}"
714
492
  while (parentType != nil)
715
- dputs "Still not nill"
716
- dp parentType
717
493
  if (parentType.is_a? ParameterizedType)
718
- dputs "Parametratized type!"
719
494
  parameterizedType = parentType;
720
495
  rawType = parameterizedType.getRawType();
721
- dp rawType, parameterizedType
722
496
  if (List.java_class.assignable_from?(rawType))
723
497
  itemType = parameterizedType.getActualTypeArguments()[0];
724
- dputs "OOOOOHHH item type is #{itemType}"
725
- dp itemType
726
498
  end
727
499
 
728
500
  break;
729
501
  end
730
502
 
731
503
  classType = parentType;
732
- dputs "checinhg generic interfaces"
733
504
  genericInterfaces = classType.generic_interfaces();
734
505
 
735
506
  genericInterfaces.each do |genericInterface|
736
- dputs "serarcing ingeraface"
737
- dp genericInterface
738
507
  if (genericInterface.is_a? ParameterizedType)
739
508
  parameterizedType = genericInterface;
740
509
  interfaceType = parameterizedType.getRawType();
741
- dputs "checking"
742
- dp parameterizedType, interfaceType
743
510
  if (List.java_class.assignable_from?(interfaceType.java_class)) || (List.java_class.assignable_from?(interfaceType.java_object))
744
511
  itemType = parameterizedType.getActualTypeArguments()[0];
745
- dputs "found it at "
746
- dp parameterizedType, interfaceType, itemType
747
- dp itemType.bounds
748
512
  break;
749
513
  end
750
514
  end
@@ -758,8 +522,6 @@ class RubyWrapperBeanAdapter
758
522
  end
759
523
 
760
524
  if (itemType != nil && itemType.is_a?(java.lang.reflect.TypeVariable))
761
- dputs 'aww shucks'
762
- dp itemType
763
525
  itemType = Java::java.lang.Object.java_class;
764
526
  end
765
527
 
@@ -996,9 +758,9 @@ class RubyWrapperBeanAdapter
996
758
 
997
759
  return allCapsBuilder.toString();
998
760
  end
999
-
761
+
1000
762
  def self.for(names)
1001
- if names.is_a? java.lang.Object
763
+ if names.is_a? java.lang.Object or (names.is_a? Java::JavaObject and (names = names.to_java))
1002
764
  RubyWrapperBeanAdapter.new(names)
1003
765
  else
1004
766
  RubyObjectWrapperBeanAdapter.new(names)