private static LineMap loadScriptMap ( Class cl ) { ClassLoader loader = cl . getClassLoader ( ) ; if ( loader == null ) return new LineMap ( ) ; // null map try { String pathName = cl . getName ( ) . replace ( ' ' , ' ' ) + ".class" ; InputStream is = loader . getResourceAsStream ( pathName ) ; if ( is == null ) return null ; try { JavaClass jClass = new ByteCodeParser ( ) . parse ( is ) ; Attribute attr = jClass . getAttribute ( "SourceDebugExtension" ) ; if ( attr == null ) { int p = cl . getName ( ) . indexOf ( ' ' ) ; if ( p > 0 ) { String className = cl . getName ( ) . substring ( 0 , p ) ; return loadScriptMap ( loader . loadClass ( className ) ) ; } return new LineMap ( ) ; } else if ( attr instanceof OpaqueAttribute ) { byte [ ] value = ( ( OpaqueAttribute ) attr ) . getValue ( ) ; ByteArrayInputStream bis = new ByteArrayInputStream ( value ) ; ReadStreamOld rs = VfsOld . openRead ( bis ) ; rs . setEncoding ( "UTF-8" ) ; try { return parseSmap ( rs ) ; } finally { rs . close ( ) ; } } else throw new IllegalStateException ( L . l ( "Expected opaque attribute at '{0}'" , attr ) ) ; } finally { if ( is != null ) is . close ( ) ; } } catch ( Throwable e ) { log . finer ( e . toString ( ) ) ; log . log ( Level . FINEST , e . toString ( ) , e ) ; return new LineMap ( ) ; // null map } }
Loads the script map for a class