Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removing code smells

  • Loading branch information...
commit a6f1183ff3c005638268cb82994fafd2f7dd7faf 1 parent 5ec28de
@qmx qmx authored headius committed
Showing with 4 additions and 13 deletions.
  1. +4 −13 src/org/jruby/javasupport/Java.java
View
17 src/org/jruby/javasupport/Java.java
@@ -1090,6 +1090,7 @@ public static IRubyObject new_proxy_instance2(IRubyObject recv, final IRubyObjec
public static IRubyObject newInterfaceImpl(final IRubyObject wrapper, Class[] interfaces) {
final Ruby runtime = wrapper.getRuntime();
+ ClassDefiningClassLoader classLoader;
Class[] tmp_interfaces = interfaces;
interfaces = new Class[tmp_interfaces.length + 1];
@@ -1099,23 +1100,23 @@ public static IRubyObject newInterfaceImpl(final IRubyObject wrapper, Class[] in
// hashcode is a combination of the interfaces and the Ruby class we're using
// to implement them
if (!RubyInstanceConfig.INTERFACES_USE_PROXY) {
- boolean cacheable = false;
int interfacesHashCode = interfacesHashCode(interfaces);
// if it's a singleton class and the real class is proc, we're doing closure conversion
// so just use Proc's hashcode
if (wrapper.getMetaClass().isSingleton() && wrapper.getMetaClass().getRealClass() == runtime.getProc()) {
interfacesHashCode = 31 * interfacesHashCode + runtime.getProc().hashCode();
- cacheable = true;
+ classLoader = runtime.getJRubyClassLoader();
} else {
// normal new class implementing interfaces
interfacesHashCode = 31 * interfacesHashCode + wrapper.getMetaClass().getRealClass().hashCode();
+ classLoader = new OneShotClassLoader(runtime.getJRubyClassLoader());
}
String implClassName = "org.jruby.gen.InterfaceImpl" + Math.abs(interfacesHashCode);
Class proxyImplClass;
try {
proxyImplClass = Class.forName(implClassName, true, runtime.getJRubyClassLoader());
} catch (ClassNotFoundException cnfe) {
- proxyImplClass = generateRealClassImplForInterfaces(wrapper, interfaces, runtime, cacheable, implClassName);
+ proxyImplClass = RealClassGenerator.createOldStyleImplClass(interfaces, wrapper.getMetaClass(), runtime, implClassName, classLoader);
}
try {
@@ -1166,16 +1167,6 @@ public Object invoke(Object proxy, Method method, Object[] nargs) throws Throwab
}
}
- private static Class generateRealClassImplForInterfaces(IRubyObject wrapper, Class[] interfaces, Ruby runtime, boolean cacheable, String implClassName) {
- ClassDefiningClassLoader classLoader;
- if (cacheable) {
- classLoader = runtime.getJRubyClassLoader();
- } else {
- classLoader = new OneShotClassLoader(runtime.getJRubyClassLoader());
- }
- return RealClassGenerator.createOldStyleImplClass(interfaces, wrapper.getMetaClass(), runtime, implClassName, classLoader);
- }
-
public static Class generateRealClass(final RubyClass clazz) {
final Ruby runtime = clazz.getRuntime();
final Class[] interfaces = getInterfacesFromRubyClass(clazz);
Please sign in to comment.
Something went wrong with that request. Please try again.