< prev index next >

src/jdk.jextract/share/classes/com/sun/tools/jextract/TypeDictionary.java

Print this page




  49     private final HeaderFile headerFile;
  50     private final Map<String, JType> functionalTypes;
  51     private final Set<String> resolutionRoots;
  52     private int serialNo;
  53 
  54     public TypeDictionary(HeaderResolver resolver, HeaderFile headerFile) {
  55         this.resolver = resolver;
  56         this.headerFile = headerFile;
  57         functionalTypes = new HashMap<>();
  58         resolutionRoots = new HashSet<>();
  59     }
  60 
  61     private int serialNo() {
  62         return ++serialNo;
  63     }
  64 
  65     private String recordOwnerClass(Type t) {
  66         try {
  67             //try resolve globally
  68             Path p = t.getDeclarationCursor().getSourceLocation().getFileLocation().path();



  69             HeaderFile hf = resolver.headerFor(p);
  70             return Utils.toInternalName(hf.pkgName, hf.headerClsName);
  71         } catch (Throwable ex) {
  72             //fallback: resolve locally. This can happen for two reasons: (i) the symbol to be resolved is a builtin
  73             //symbol (e.g. no header file has its definition), or (ii) when the declaration cursor points to an header file
  74             //not previously seen by Context.
  75                 return headerClass();
  76         }
  77     }
  78 
  79     private String headerClass() {
  80         return Utils.toInternalName(headerFile.pkgName, headerFile.headerClsName);
  81     }
  82 
  83     public Stream<JType> functionalInterfaces() {
  84         return functionalTypes.entrySet().stream()
  85                 .map(Map.Entry::getValue);
  86     }
  87 
  88     public Stream<JType.ClassType> resolutionRoots() {




  49     private final HeaderFile headerFile;
  50     private final Map<String, JType> functionalTypes;
  51     private final Set<String> resolutionRoots;
  52     private int serialNo;
  53 
  54     public TypeDictionary(HeaderResolver resolver, HeaderFile headerFile) {
  55         this.resolver = resolver;
  56         this.headerFile = headerFile;
  57         functionalTypes = new HashMap<>();
  58         resolutionRoots = new HashSet<>();
  59     }
  60 
  61     private int serialNo() {
  62         return ++serialNo;
  63     }
  64 
  65     private String recordOwnerClass(Type t) {
  66         try {
  67             //try resolve globally
  68             Path p = t.getDeclarationCursor().getSourceLocation().getFileLocation().path();
  69             if (p == null) {
  70                 p = Context.getBuiltinHeaderFile();
  71             }
  72             HeaderFile hf = resolver.headerFor(p);
  73             return Utils.toInternalName(hf.pkgName, hf.headerClsName);
  74         } catch (Throwable ex) {
  75             //fallback: resolve locally. This can happen for two reasons: (i) the symbol to be resolved is a builtin
  76             //symbol (e.g. no header file has its definition), or (ii) when the declaration cursor points to an header file
  77             //not previously seen by Context.
  78                 return headerClass();
  79         }
  80     }
  81 
  82     private String headerClass() {
  83         return Utils.toInternalName(headerFile.pkgName, headerFile.headerClsName);
  84     }
  85 
  86     public Stream<JType> functionalInterfaces() {
  87         return functionalTypes.entrySet().stream()
  88                 .map(Map.Entry::getValue);
  89     }
  90 
  91     public Stream<JType.ClassType> resolutionRoots() {


< prev index next >