Skip to content

Commit

Permalink
avoid regression in loading Java classes with upper case package names (
Browse files Browse the repository at this point in the history
fixes jruby#2742)

... caused by the internal cleanup (the regression is not part of any 1.7.x release)

one can only test this with *-Xji.upper.case.package.name.allowed=true* but since there's another failure the feature introduces, this will need to be revisited
  • Loading branch information
kares committed Mar 24, 2015
1 parent adeb887 commit 7d9d2ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,13 @@ private static RubyModule getProxyOrPackageUnderPackage(final ThreadContext cont
// we'll try as a package
result = getJavaPackageModule(runtime, fullName);
// NOTE result = getPackageModule(runtime, name);
if ( result == null ) {
throw runtime.newNameError("missing class (or package) name (`" + fullName + "')", fullName);
}
}
else {
throw runtime.newNameError("missing class name (`" + fullName + "')", fullName);
}
throw runtime.newNameError("missing class name (`" + fullName + "')", fullName);
}
}
catch (RuntimeException e) {
Expand Down
19 changes: 18 additions & 1 deletion test/test_higher_javasupport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class TestHigherJavasupport < Test::Unit::TestCase
Annotation = java.lang.annotation.Annotation
ClassWithPrimitive = org.jruby.test.ClassWithPrimitive

ALLOW_UPPERCASE_PACKAGE_NAMES = JRuby.runtime.getInstanceConfig.getAllowUppercasePackageNames

def test_java_int_primitive_assignment
assert_nothing_raised {
cwp = ClassWithPrimitive.new
Expand Down Expand Up @@ -447,8 +449,10 @@ def test_expected_missing_interface_method
end

def test_that_misspelt_fq_class_names_dont_stop_future_fq_class_names_with_same_inner_most_package
# NOTE: with ALLOW_UPPERCASE_PACKAGE_NAMES this raises nothing !
assert_raises(NameError) { Java::java.til.zip.ZipFile }
assert_nothing_raised { Java::java.util.zip.ZipFile }
Java::java.util.zip.ZipFile
Java::java.util.zip.ZipFile::OPEN_READ
end

def test_that_subpackages_havent_leaked_into_other_packages
Expand All @@ -465,6 +469,19 @@ def test_that_we_get_the_same_package_instance_on_subsequent_calls
assert(com.flirble.equal?(com.flirble))
end

def test_uppercase_package_name_and_lowercase_class_name # and upper-case method
Java::org.jruby.javasupport.TestApp
Java::org.jruby.javasupport.TestApp.UpperClass
assert_equal 'UGLY!', Java::org.jruby.javasupport.TestApp::UpperClass.UglyMethod

Java::org.jruby.javasupport.TestApp::lowerClass
assert_equal 'ugly!', Java::org.jruby.javasupport.TestApp.lowerClass.UglyMethod

# NOTE: can not work due package case conventions :
# Java::OrgJrubyJavasupportTestApp::UpperClass
# Java::OrgJrubyJavasupportTestApp::lowerClass
end if ALLOW_UPPERCASE_PACKAGE_NAMES

@@include_proc = Proc.new do
Thread.stop
java_import "java.lang.System"
Expand Down

0 comments on commit 7d9d2ba

Please sign in to comment.