Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static Class defineOldStyleImplClass(final Ruby ruby, final String name,
String pathName = name.replace('.', '/');

// construct the class, implementing all supertypes
cw.visit(V_BC, ACC_PUBLIC | ACC_SUPER, pathName, null, p(Object.class), superTypeNames);
cw.visit(V_BC, ACC_PUBLIC | ACC_SUPER | ACC_SYNTHETIC, pathName, null, p(Object.class), superTypeNames);
cw.visitSource(pathName + ".gen", null);

// fields needed for dispatch and such
Expand Down
4 changes: 3 additions & 1 deletion core/src/main/java/org/jruby/javasupport/Java.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,9 @@ else if ( clazz == Object.class ) {
for ( int i = interfaces.length; --i >= 0; ) {
proxy.includeModule(getInterfaceModule(runtime, interfaces[i]));
}
if ( Modifier.isPublic(clazz.getModifiers()) ) {
// we don't want to expose any synthetic classes into Ruby constants,
// JRuby generated classes such as interface impls (org.jruby.gen.InterfaceImpl) are marked synthetic
if (Modifier.isPublic(clazz.getModifiers()) && !clazz.isSynthetic()) {
addToJavaPackageModule(proxy);
}
}
Expand Down
23 changes: 23 additions & 0 deletions test/jruby/test_higher_javasupport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,29 @@ def test_indexed_bean_style_accessors_are_not_aliased
end
end

def test_no_warnings_on_interface_impls_being_set_as_constants
runner_base = Class.new do
class << self
def run; self != self end
end
end

runner_impl1 = Class.new(runner_base)
runner_impl2 = Class.new(runner_base)
runner_impl3 = Class.new(runner_base)

output = with_stderr_captured do
threads = []
threads << java.lang.Thread.new(runner_impl1)
threads << java.lang.Thread.new(runner_impl2)
threads << java.lang.Thread.new(runner_impl3)
threads.each(&:start)
threads.each(&:join)
end
# expect no warning: already initialized constant org.jruby.gen::InterfaceImpl1353309827
refute output.index('already initialized constant'), output
end

def test_no_warnings_on_concurrent_package_const_initialization
output = with_stderr_captured do
threads = (0..10).map do # smt not yet initialized :
Expand Down
Loading