core/src/main/java/org/jruby/RubyClass.java
public synchronized void reify(String classDumpDir, boolean useChildLoader) {
        // re-check reifiable in case another reify call has jumped in ahead of us
        if (!isReifiable()) return;

        // calculate an appropriate name, for anonymous using inspect like format e.g. "Class:0x628fad4a"
        final String name = getBaseName() != null ? getName() :
                ( "Class_0x" + Integer.toHexString(System.identityHashCode(this)) );

        final String javaName = "rubyobj." + StringSupport.replaceAll(name, "::", ".");
        final String javaPath = "rubyobj/" + StringSupport.replaceAll(name, "::", "/");

        final Class parentReified = superClass.getRealClass().getReifiedClass();
        if (parentReified == null) {
            throw getClassRuntime().newTypeError(getName() + "'s parent class is not yet reified");
        }

        Class reifiedParent = RubyObject.class;
        if (superClass.reifiedClass != null) reifiedParent = superClass.reifiedClass;

        final byte[] classBytes = new MethodReificator(reifiedParent, javaName, javaPath).reify();

        final ClassDefiningClassLoader parentCL;
        if (parentReified.getClassLoader() instanceof OneShotClassLoader) {
            parentCL = (OneShotClassLoader) parentReified.getClassLoader();
        } else {
            if (useChildLoader) {
                parentCL = new OneShotClassLoader(runtime.getJRubyClassLoader());
            } else {
                parentCL = runtime.getJRubyClassLoader();
            }
        }
        // Attempt to load the name we plan to use; skip reification if it exists already (see #1229).
        try {
            Class result = parentCL.defineClass(javaName, classBytes);
            dumpReifiedClass(classDumpDir, javaPath, classBytes);

            @SuppressWarnings("unchecked")
            java.lang.reflect.Method clinit = result.getDeclaredMethod("clinit", Ruby.class, RubyClass.class);
            clinit.invoke(null, runtime, this);

            setClassAllocator(result);
            reifiedClass = result;

            return; // success
        }
        catch (LinkageError error) { // fall through to failure path
            final String msg = error.getMessage();
            if ( msg != null && msg.contains("duplicate class definition for name") ) {
                logReifyException(error, false);
            }
            else {
                logReifyException(error, true);
            }
        }
        catch (Exception ex) {
            logReifyException(ex, true);
        }

        // If we get here, there's some other class in this classloader hierarchy with the same name. In order to
        // avoid a naming conflict, we set reified class to parent and skip reification.

        if (superClass.reifiedClass != null) {
            reifiedClass = superClass.reifiedClass;
            allocator = superClass.allocator;
        }
    }
/**
     * Stand up a real Java class for the backing store of this object
     * @param classDumpDir Directory to save reified java class
     */
Stand up a real Java class for the backing store of this object
@param classDumpDir Directory to save reified java class
Stand up a real Java class for the backing store of this object @param classDumpDir Directory to save reified java class
public synchronized void reify(String classDumpDir, boolean useChildLoader) {
        if (!isReifiable()) return;
        final String name = getBaseName() != null ? getName() :
                ( "Class_0x" + Integer.toHexString(System.identityHashCode(this)) );
        final String javaName = "rubyobj." + StringSupport.replaceAll(name, "::", ".");
        final String javaPath = "rubyobj/" + StringSupport.replaceAll(name, "::", "/");
        final Class parentReified = superClass.getRealClass().getReifiedClass();
        if (parentReified == null) {
            throw getClassRuntime().newTypeError(getName() + "'s parent class is not yet reified");
        }
        Class reifiedParent = RubyObject.class;
        if (superClass.reifiedClass != null) reifiedParent = superClass.reifiedClass;
        final byte[] classBytes = new MethodReificator(reifiedParent, javaName, javaPath).reify();
        final ClassDefiningClassLoader parentCL;
        if (parentReified.getClassLoader() instanceof OneShotClassLoader) {
            parentCL = (OneShotClassLoader) parentReified.getClassLoader();
        } else {
            if (useChildLoader) {
                parentCL = new OneShotClassLoader(runtime.getJRubyClassLoader());
            } else {
                parentCL = runtime.getJRubyClassLoader();
            }
        }
        try {
            Class result = parentCL.defineClass(javaName, classBytes);
            dumpReifiedClass(classDumpDir, javaPath, classBytes);
            @SuppressWarnings("unchecked")
            java.lang.reflect.Method clinit = result.getDeclaredMethod("clinit", Ruby.class, RubyClass.class);
            clinit.invoke(null, runtime, this);
            setClassAllocator(result);
            reifiedClass = result;
            return; 
        }
        catch (LinkageError error) { 
            final String msg = error.getMessage();
            if ( msg != null && msg.contains("duplicate class definition for name") ) {
                logReifyException(error, false);
            }
            else {
                logReifyException(error, true);
            }
        }
        catch (Exception ex) {
            logReifyException(ex, true);
        }
        if (superClass.reifiedClass != null) {
            reifiedClass = superClass.reifiedClass;
            allocator = superClass.allocator;
        }
    }
public synchronized void reify ( String classDumpDir , boolean useChildLoader ) { if ( ! isReifiable ( ) ) return ; final String name = getBaseName ( ) != null ? getName ( ) : ( "Class_0x" + Integer . toHexString ( System . identityHashCode ( this ) ) ) ; final String javaName = "rubyobj." + StringSupport . replaceAll ( name , "::" , "." ) ; final String javaPath = "rubyobj/" + StringSupport . replaceAll ( name , "::" , "/" ) ; final Class parentReified = superClass . getRealClass ( ) . getReifiedClass ( ) ; if ( parentReified == null ) { throw getClassRuntime ( ) . newTypeError ( getName ( ) + "'s parent class is not yet reified" ) ; } Class reifiedParent = RubyObject . class ; if ( superClass . reifiedClass != null ) reifiedParent = superClass . reifiedClass ; final byte [ ] classBytes = new MethodReificator ( reifiedParent , javaName , javaPath ) . reify ( ) ; final ClassDefiningClassLoader parentCL ; if ( parentReified . getClassLoader ( ) instanceof OneShotClassLoader ) { parentCL = ( OneShotClassLoader ) parentReified . getClassLoader ( ) ; } else { if ( useChildLoader ) { parentCL = new OneShotClassLoader ( runtime . getJRubyClassLoader ( ) ) ; } else { parentCL = runtime . getJRubyClassLoader ( ) ; } } try { Class result = parentCL . defineClass ( javaName , classBytes ) ; dumpReifiedClass ( classDumpDir , javaPath , classBytes ) ; @ SuppressWarnings ( "unchecked" ) java . lang . reflect . Method clinit = result . getDeclaredMethod ( "clinit" , Ruby . class , RubyClass . class ) ; clinit . invoke ( null , runtime , this ) ; setClassAllocator ( result ) ; reifiedClass = result ; return ; } catch ( LinkageError error ) { final String msg = error . getMessage ( ) ; if ( msg != null && msg . contains ( "duplicate class definition for name" ) ) { logReifyException ( error , false ) ; } else { logReifyException ( error , true ) ; } } catch ( Exception ex ) { logReifyException ( ex , true ) ; } if ( superClass . reifiedClass != null ) { reifiedClass = superClass . reifiedClass ; allocator = superClass . allocator ; } }
Stand up a real Java class for the backing store of this object
 @param classDumpDir Directory to save reified java class
Stand up a real Java class for the backing store of this object @param classDumpDir Directory to save reified java class
// re-check reifiable in case another reify call has jumped in ahead of us // calculate an appropriate name, for anonymous using inspect like format e.g. "Class:0x628fad4a" // Attempt to load the name we plan to use; skip reification if it exists already (see #1229). // success // fall through to failure path // If we get here, there's some other class in this classloader hierarchy with the same name. In order to // avoid a naming conflict, we set reified class to parent and skip reification.