Permalink
Browse files

Applying Vladimir's fix for JRUBY-2106 to a couple of other spots (to…

…p-level Java package references, as in Java::boom or Java::Boom). Regression tests included.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@5923 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information...
1 parent cd84f1b commit 5fcc77227127a71f6c4215152b6be8e6469a6589 @bdortch bdortch committed Feb 13, 2008
Showing with 29 additions and 4 deletions.
  1. +17 −3 src/org/jruby/javasupport/Java.java
  2. +12 −1 test/test_higher_javasupport.rb
@@ -635,6 +635,11 @@ public static RubyModule getTopLevelProxyOrPackage(final Ruby runtime, String sy
// this covers primitives and (unlikely) lower-case class names
try {
return getProxyClass(runtime, JavaClass.forName(runtime, name));
+ } catch (RaiseException re) { /* not primitive or lc class */
+ RubyException rubyEx = re.getException();
+ if (rubyEx.kind_of_p(runtime.getStandardError()).isTrue()) {
+ RuntimeHelpers.setErrorInfo(runtime, runtime.getNil());
+ }
} catch (Exception e) { /* not primitive or lc class */ }
// TODO: check for Java reserved names and raise exception if encountered
@@ -667,9 +672,18 @@ public Arity getArity() {
} else {
try {
return getProxyClass(runtime, JavaClass.forName(runtime, name));
- } catch (Exception e) {
- return getPackageModule(runtime, name);
- }
+ } catch (RaiseException re) { /* not a class */
+ RubyException rubyEx = re.getException();
+ if (rubyEx.kind_of_p(runtime.getStandardError()).isTrue()) {
+ RuntimeHelpers.setErrorInfo(runtime, runtime.getNil());
+ }
+ } catch (Exception e) { /* not a class */ }
+
+ // upper-case package name
+ // TODO: top-level upper-case package was supported in the previous (Ruby-based)
+ // implementation, so leaving as is. see note at #getProxyOrPackageUnderPackage
+ // re: future approach below the top-level.
+ return getPackageModule(runtime, name);
}
}
@@ -674,9 +674,20 @@ def test_package_module_aliased_methods
end
# JRUBY-2106
- def test_package_load_doesn_set_error
+ def test_package_load_doesnt_set_error
$! = nil
undo = javax.swing.undo
assert_nil($!)
end
+
+ # JRUBY-2106
+ def test_top_level_package_load_doesnt_set_error
+ $! = nil
+ Java::boom
+ assert_nil($!)
+
+ $! = nil
+ Java::Boom
+ assert_nil($!)
+ end
end

0 comments on commit 5fcc772

Please sign in to comment.