< prev index next >

make/langtools/src/classes/build/tools/symbolgenerator/CreateSymbols.java

Print this page

 289                     jos.write(fd.fileData);
 290                 }
 291             }
 292         }
 293     }
 294 
 295     private static final String PREVIEW_FEATURE_ANNOTATION_OLD =
 296             "Ljdk/internal/PreviewFeature;";
 297     private static final String PREVIEW_FEATURE_ANNOTATION_NEW =
 298             "Ljdk/internal/javac/PreviewFeature;";
 299     private static final String PREVIEW_FEATURE_ANNOTATION_INTERNAL =
 300             "Ljdk/internal/PreviewFeature+Annotation;";
 301     private static final String RESTRICTED_ANNOTATION =
 302             "Ljdk/internal/javac/Restricted;";
 303     private static final String RESTRICTED_ANNOTATION_INTERNAL =
 304             "Ljdk/internal/javac/Restricted+Annotation;";
 305     private static final String VALUE_BASED_ANNOTATION =
 306             "Ljdk/internal/ValueBased;";
 307     private static final String VALUE_BASED_ANNOTATION_INTERNAL =
 308             "Ljdk/internal/ValueBased+Annotation;";




 309     private static final String REQUIRES_IDENTITY_ANNOTATION =
 310             "Ljdk/internal/RequiresIdentity;";
 311     private static final String REQUIRES_IDENTITY_ANNOTATION_INTERNAL =
 312             "Ljdk/internal/RequiresIdentity+Annotation;";
 313     public static final Set<String> HARDCODED_ANNOTATIONS = new HashSet<>(
 314             List.of("Ljdk/Profile+Annotation;",
 315                     "Lsun/Proprietary+Annotation;",
 316                     PREVIEW_FEATURE_ANNOTATION_OLD,
 317                     PREVIEW_FEATURE_ANNOTATION_NEW,
 318                     VALUE_BASED_ANNOTATION,

 319                     RESTRICTED_ANNOTATION,
 320                     REQUIRES_IDENTITY_ANNOTATION));
 321 
 322     private void stripNonExistentAnnotations(LoadDescriptions data) {
 323         Set<String> allClasses = data.classes.name2Class.keySet();
 324         data.modules.values().forEach(mod -> {
 325             stripNonExistentAnnotations(allClasses, mod.header);
 326         });
 327         data.classes.classes.forEach(clazz -> {
 328             stripNonExistentAnnotations(allClasses, clazz.header);
 329             stripNonExistentAnnotations(allClasses, clazz.fields);
 330             stripNonExistentAnnotations(allClasses, clazz.methods);
 331         });
 332     }
 333 
 334     private void stripNonExistentAnnotations(Set<String> allClasses, Iterable<? extends FeatureDescription> descs) {
 335         descs.forEach(d -> stripNonExistentAnnotations(allClasses, d));
 336     }
 337 
 338     private void stripNonExistentAnnotations(Set<String> allClasses, FeatureDescription d) {

1017             //the non-public PreviewFeature annotation will not be available in ct.sym,
1018             //replace with purely synthetic javac-internal annotation:
1019             annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
1020         }
1021 
1022         if (PREVIEW_FEATURE_ANNOTATION_OLD.equals(annotationType)) {
1023             //the non-public PreviewFeature annotation will not be available in ct.sym,
1024             //replace with purely synthetic javac-internal annotation:
1025             annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
1026             values = new HashMap<>(values);
1027             Boolean essentialAPI = (Boolean) values.remove("essentialAPI");
1028             values.put("reflective", essentialAPI != null && !essentialAPI);
1029         }
1030 
1031         if (VALUE_BASED_ANNOTATION.equals(annotationType)) {
1032             //the non-public ValueBased annotation will not be available in ct.sym,
1033             //replace with purely synthetic javac-internal annotation:
1034             annotationType = VALUE_BASED_ANNOTATION_INTERNAL;
1035         }
1036 






1037         if (REQUIRES_IDENTITY_ANNOTATION.equals(annotationType)) {
1038             //the non-public RequiresIdentity annotation will not be available in ct.sym,
1039             //replace with purely synthetic javac-internal annotation:
1040             annotationType = REQUIRES_IDENTITY_ANNOTATION_INTERNAL;
1041         }
1042 
1043         if (RESTRICTED_ANNOTATION.equals(annotationType)) {
1044             //the non-public Restricted annotation will not be available in ct.sym,
1045             //replace with purely synthetic javac-internal annotation:
1046             annotationType = RESTRICTED_ANNOTATION_INTERNAL;
1047         }
1048 
1049         return Annotation.of(ClassDesc.ofDescriptor(annotationType),
1050                 createElementPairs(values));
1051     }
1052 
1053     private List<AnnotationElement> createElementPairs(Map<String, Object> annotationAttributes) {
1054         return annotationAttributes.entrySet().stream()
1055                 .map(e -> AnnotationElement.of(e.getKey(), createAttributeValue(e.getValue())))
1056                 .collect(Collectors.toList());

 289                     jos.write(fd.fileData);
 290                 }
 291             }
 292         }
 293     }
 294 
 295     private static final String PREVIEW_FEATURE_ANNOTATION_OLD =
 296             "Ljdk/internal/PreviewFeature;";
 297     private static final String PREVIEW_FEATURE_ANNOTATION_NEW =
 298             "Ljdk/internal/javac/PreviewFeature;";
 299     private static final String PREVIEW_FEATURE_ANNOTATION_INTERNAL =
 300             "Ljdk/internal/PreviewFeature+Annotation;";
 301     private static final String RESTRICTED_ANNOTATION =
 302             "Ljdk/internal/javac/Restricted;";
 303     private static final String RESTRICTED_ANNOTATION_INTERNAL =
 304             "Ljdk/internal/javac/Restricted+Annotation;";
 305     private static final String VALUE_BASED_ANNOTATION =
 306             "Ljdk/internal/ValueBased;";
 307     private static final String VALUE_BASED_ANNOTATION_INTERNAL =
 308             "Ljdk/internal/ValueBased+Annotation;";
 309     private static final String MIGRATED_VALUE_CLASS_ANNOTATION =
 310             "Ljdk/internal/MigratedValueClass;";
 311     private static final String MIGRATED_VALUE_CLASS_ANNOTATION_INTERNAL =
 312             "Ljdk/internal/MigratedValueClass+Annotation;";
 313     private static final String REQUIRES_IDENTITY_ANNOTATION =
 314             "Ljdk/internal/RequiresIdentity;";
 315     private static final String REQUIRES_IDENTITY_ANNOTATION_INTERNAL =
 316             "Ljdk/internal/RequiresIdentity+Annotation;";
 317     public static final Set<String> HARDCODED_ANNOTATIONS = new HashSet<>(
 318             List.of("Ljdk/Profile+Annotation;",
 319                     "Lsun/Proprietary+Annotation;",
 320                     PREVIEW_FEATURE_ANNOTATION_OLD,
 321                     PREVIEW_FEATURE_ANNOTATION_NEW,
 322                     VALUE_BASED_ANNOTATION,
 323                     MIGRATED_VALUE_CLASS_ANNOTATION,
 324                     RESTRICTED_ANNOTATION,
 325                     REQUIRES_IDENTITY_ANNOTATION));
 326 
 327     private void stripNonExistentAnnotations(LoadDescriptions data) {
 328         Set<String> allClasses = data.classes.name2Class.keySet();
 329         data.modules.values().forEach(mod -> {
 330             stripNonExistentAnnotations(allClasses, mod.header);
 331         });
 332         data.classes.classes.forEach(clazz -> {
 333             stripNonExistentAnnotations(allClasses, clazz.header);
 334             stripNonExistentAnnotations(allClasses, clazz.fields);
 335             stripNonExistentAnnotations(allClasses, clazz.methods);
 336         });
 337     }
 338 
 339     private void stripNonExistentAnnotations(Set<String> allClasses, Iterable<? extends FeatureDescription> descs) {
 340         descs.forEach(d -> stripNonExistentAnnotations(allClasses, d));
 341     }
 342 
 343     private void stripNonExistentAnnotations(Set<String> allClasses, FeatureDescription d) {

1022             //the non-public PreviewFeature annotation will not be available in ct.sym,
1023             //replace with purely synthetic javac-internal annotation:
1024             annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
1025         }
1026 
1027         if (PREVIEW_FEATURE_ANNOTATION_OLD.equals(annotationType)) {
1028             //the non-public PreviewFeature annotation will not be available in ct.sym,
1029             //replace with purely synthetic javac-internal annotation:
1030             annotationType = PREVIEW_FEATURE_ANNOTATION_INTERNAL;
1031             values = new HashMap<>(values);
1032             Boolean essentialAPI = (Boolean) values.remove("essentialAPI");
1033             values.put("reflective", essentialAPI != null && !essentialAPI);
1034         }
1035 
1036         if (VALUE_BASED_ANNOTATION.equals(annotationType)) {
1037             //the non-public ValueBased annotation will not be available in ct.sym,
1038             //replace with purely synthetic javac-internal annotation:
1039             annotationType = VALUE_BASED_ANNOTATION_INTERNAL;
1040         }
1041 
1042         if (MIGRATED_VALUE_CLASS_ANNOTATION.equals(annotationType)) {
1043             //the non-public MigratedValueClass annotation will not be available in ct.sym,
1044             //replace with purely synthetic javac-internal annotation:
1045             annotationType = MIGRATED_VALUE_CLASS_ANNOTATION_INTERNAL;
1046         }
1047 
1048         if (REQUIRES_IDENTITY_ANNOTATION.equals(annotationType)) {
1049             //the non-public RequiresIdentity annotation will not be available in ct.sym,
1050             //replace with purely synthetic javac-internal annotation:
1051             annotationType = REQUIRES_IDENTITY_ANNOTATION_INTERNAL;
1052         }
1053 
1054         if (RESTRICTED_ANNOTATION.equals(annotationType)) {
1055             //the non-public Restricted annotation will not be available in ct.sym,
1056             //replace with purely synthetic javac-internal annotation:
1057             annotationType = RESTRICTED_ANNOTATION_INTERNAL;
1058         }
1059 
1060         return Annotation.of(ClassDesc.ofDescriptor(annotationType),
1061                 createElementPairs(values));
1062     }
1063 
1064     private List<AnnotationElement> createElementPairs(Map<String, Object> annotationAttributes) {
1065         return annotationAttributes.entrySet().stream()
1066                 .map(e -> AnnotationElement.of(e.getKey(), createAttributeValue(e.getValue())))
1067                 .collect(Collectors.toList());
< prev index next >