Skip to content

Commit 822abec

Browse files
committed
Merge remote-tracking branch 'origin/master' into update_stdlib
2 parents 668a4bd + 1df19df commit 822abec

File tree

1 file changed

+8
-0
lines changed
  • core/src/main/ruby/jruby/java/core_ext

1 file changed

+8
-0
lines changed

core/src/main/ruby/jruby/java/core_ext/object.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ def java_import(*import_classes)
2222
import_classes.map do |import_class|
2323
case import_class
2424
when String
25+
cc = java.lang.Character
26+
valid_name = import_class.split(".").all? do |frag|
27+
cc.java_identifier_start? frag[0].ord and
28+
frag.each_char.all? {|c| cc.java_identifier_part? c.ord }
29+
end
30+
unless valid_name
31+
raise ArgumentError.new "not a valid Java identifier: #{import_class}"
32+
end
2533
# pull in the class
2634
import_class = JavaUtilities.get_proxy_class(import_class)
2735
when Module

0 commit comments

Comments
 (0)