@ Deprecated public PackageDoc [ ] importedPackages ( ) { // information is not available for binary classfiles if ( tsym . sourcefile == null ) return new PackageDoc [ 0 ] ; ListBuffer < PackageDocImpl > importedPackages = new ListBuffer <> ( ) ; //### Add the implicit "import java.lang.*" to the result Names names = tsym . name . table . names ; importedPackages . append ( env . getPackageDoc ( env . syms . enterPackage ( env . syms . java_base , names . java_lang ) ) ) ; Env < AttrContext > compenv = env . enter . getEnv ( tsym ) ; if ( compenv == null ) return new PackageDocImpl [ 0 ] ; for ( JCTree t : compenv . toplevel . defs ) { if ( t . hasTag ( IMPORT ) ) { JCTree imp = ( ( JCImport ) t ) . qualid ; if ( TreeInfo . name ( imp ) == names . asterisk ) { JCFieldAccess sel = ( JCFieldAccess ) imp ; Symbol s = sel . selected . type . tsym ; PackageDocImpl pdoc = env . getPackageDoc ( s . packge ( ) ) ; if ( ! importedPackages . contains ( pdoc ) ) importedPackages . append ( pdoc ) ; } } } return importedPackages . toArray ( new PackageDocImpl [ importedPackages . length ( ) ] ) ; }
Get the list of packages declared as imported . These are called type - import - on - demand declarations in the JLS . This method is deprecated in the ClassDoc interface .