1.1 --- a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Mon Jan 21 00:45:35 2013 -0500 1.2 +++ b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Mon Jan 21 01:27:42 2013 -0500 1.3 @@ -34,11 +34,11 @@ 1.4 import com.sun.tools.javac.code.Symtab; 1.5 import com.sun.tools.javac.code.Type; 1.6 import com.sun.tools.javac.code.Types; 1.7 -import com.sun.tools.javac.jvm.ClassReader; 1.8 import com.sun.tools.javac.jvm.ClassWriter; 1.9 import com.sun.tools.javac.jvm.Pool; 1.10 import com.sun.tools.javac.processing.JavacProcessingEnvironment; 1.11 import com.sun.tools.javac.util.List; 1.12 +import com.sun.tools.javac.util.Names; 1.13 import com.sun.tools.javac.util.Pair; 1.14 1.15 import java.io.File; 1.16 @@ -47,6 +47,7 @@ 1.17 import java.util.EnumSet; 1.18 import java.util.Enumeration; 1.19 import java.util.HashSet; 1.20 +import java.util.Map; 1.21 import java.util.ResourceBundle; 1.22 import java.util.Set; 1.23 1.24 @@ -85,7 +86,10 @@ 1.25 * 1.26 * @author Peter von der Ah\u00e9 1.27 */ 1.28 -@SupportedOptions({"com.sun.tools.javac.sym.Jar","com.sun.tools.javac.sym.Dest"}) 1.29 +@SupportedOptions({ 1.30 + "com.sun.tools.javac.sym.Jar", 1.31 + "com.sun.tools.javac.sym.Dest", 1.32 + "com.sun.tools.javac.sym.Profiles"}) 1.33 @SupportedAnnotationTypes("*") 1.34 public class CreateSymbols extends AbstractProcessor { 1.35 1.36 @@ -106,6 +110,7 @@ 1.37 processingEnv.getMessager() 1.38 .printMessage(Diagnostic.Kind.ERROR, e.getLocalizedMessage()); 1.39 } catch (Throwable t) { 1.40 + t.printStackTrace(); 1.41 Throwable cause = t.getCause(); 1.42 if (cause == null) 1.43 cause = t; 1.44 @@ -121,12 +126,17 @@ 1.45 Set<String> documented = new HashSet<String>(); 1.46 Set<PackageSymbol> packages = 1.47 ((JavacProcessingEnvironment)processingEnv).getSpecifiedPackages(); 1.48 - String jarName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Jar"); 1.49 + Map<String,String> pOptions = processingEnv.getOptions(); 1.50 + String jarName = pOptions.get("com.sun.tools.javac.sym.Jar"); 1.51 if (jarName == null) 1.52 throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Jar=LOCATION_OF_JAR"); 1.53 - String destName = processingEnv.getOptions().get("com.sun.tools.javac.sym.Dest"); 1.54 + String destName = pOptions.get("com.sun.tools.javac.sym.Dest"); 1.55 if (destName == null) 1.56 throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Dest=LOCATION_OF_JAR"); 1.57 + String profileSpec=pOptions.get("com.sun.tools.javac.sym.Profiles"); 1.58 + if (profileSpec == null) 1.59 + throw new RuntimeException("Must use -Acom.sun.tools.javac.sym.Profiles=PROFILES_SPEC"); 1.60 + Profiles profiles = Profiles.read(new File(profileSpec)); 1.61 1.62 for (PackageSymbol psym : packages) { 1.63 String name = psym.getQualifiedName().toString(); 1.64 @@ -166,12 +176,19 @@ 1.65 tool.getTask(null, fm, null, options, null, null); 1.66 com.sun.tools.javac.main.JavaCompiler compiler = 1.67 com.sun.tools.javac.main.JavaCompiler.instance(task.getContext()); 1.68 - ClassReader reader = ClassReader.instance(task.getContext()); 1.69 ClassWriter writer = ClassWriter.instance(task.getContext()); 1.70 Symtab syms = Symtab.instance(task.getContext()); 1.71 - Attribute.Compound proprietary = 1.72 + Names names = Names.instance(task.getContext()); 1.73 + Attribute.Compound proprietaryAnno = 1.74 new Attribute.Compound(syms.proprietaryType, 1.75 List.<Pair<Symbol.MethodSymbol,Attribute>>nil()); 1.76 + Attribute.Compound[] profileAnnos = new Attribute.Compound[profiles.getProfileCount() + 1]; 1.77 + Symbol.MethodSymbol profileValue = (MethodSymbol) syms.profileType.tsym.members().lookup(names.value).sym; 1.78 + for (int i = 1; i < profileAnnos.length; i++) { 1.79 + profileAnnos[i] = new Attribute.Compound(syms.profileType, 1.80 + List.<Pair<Symbol.MethodSymbol, Attribute>>of( 1.81 + new Pair<Symbol.MethodSymbol, Attribute>(profileValue, new Attribute.Constant(syms.intType, i)))); 1.82 + } 1.83 1.84 Type.moreInfo = true; 1.85 Types types = Types.instance(task.getContext()); 1.86 @@ -208,8 +225,11 @@ 1.87 } 1.88 ClassSymbol cs = (ClassSymbol) sym; 1.89 if (addLegacyAnnotation) { 1.90 - cs.annotations.prepend(List.of(proprietary)); 1.91 + cs.annotations.prepend(List.of(proprietaryAnno)); 1.92 } 1.93 + int p = profiles.getProfile(cs.fullname.toString().replace(".", "/")); 1.94 + if (0 < p && p < profileAnnos.length) 1.95 + cs.annotations.prepend(List.of(profileAnnos[p])); 1.96 writeClass(pool, cs, writer); 1.97 } 1.98