private static Entry findClassPathEntry ( Entry jarEntry , URI pathUri ) throws URISyntaxException , UnableToAdaptException { URI relativeJarUri = new URI ( "/" ) . relativize ( new URI ( jarEntry . getPath ( ) ) ) ; URI targetUri = null ; targetUri = relativeJarUri . resolve ( pathUri ) ; if ( targetUri . toString ( ) . startsWith ( ".." ) ) { Entry rootEntry = jarEntry . getRoot ( ) . adapt ( Entry . class ) ; if ( rootEntry == null || rootEntry . getPath ( ) . isEmpty ( ) ) { //already at the outermost return null ; } return findClassPathEntry ( rootEntry , new URI ( ".." ) . relativize ( targetUri ) ) ; // <---- } else { return jarEntry . getRoot ( ) . getEntry ( targetUri . toString ( ) ) ; } }
calculate the class path entry based on the jar entry