private void loadStorageForFetch ( CodeBuilder b , TypeDesc type ) { b . loadThis ( ) ; b . loadField ( SUPPORT_FIELD_NAME , mSupportType ) ; TypeDesc storageType = TypeDesc . forClass ( Storage . class ) ; TypeDesc repositoryType = TypeDesc . forClass ( Repository . class ) ; b . invokeInterface ( mSupportType , "getRootRepository" , repositoryType , null ) ; b . loadConstant ( type ) ; // This may throw a RepositoryException. Label tryStart = b . createLabel ( ) . setLocation ( ) ; b . invokeInterface ( repositoryType , STORAGE_FOR_METHOD_NAME , storageType , new TypeDesc [ ] { TypeDesc . forClass ( Class . class ) } ) ; Label tryEnd = b . createLabel ( ) . setLocation ( ) ; Label noException = b . createLabel ( ) ; b . branch ( noException ) ; b . exceptionHandler ( tryStart , tryEnd , RepositoryException . class . getName ( ) ) ; b . invokeVirtual ( RepositoryException . class . getName ( ) , "toFetchException" , TypeDesc . forClass ( FetchException . class ) , null ) ; b . throwObject ( ) ; noException . setLocation ( ) ; }
Generates code that loads a Storage instance on the stack throwing a FetchException if Storage request fails .