Future of 'type-annotations/type-annotations' forest

Michael Ernst mernst at cs.washington.edu
Tue May 20 04:06:59 UTC 2014


Jonathan-

Thanks for the information.  We understand the risks.  But there is 
significant information that we simply cannot do without -- information 
that is only available through the unsupported APIs, so we'll keep using 
them.  My kingdom for JSR 198...

                     -Mike


> Subject: Re: Future of 'type-annotations/type-annotations' forest
> From: Jonathan Gibbons <jonathan.gibbons at oracle.com>
> To: Werner Dietl <wdietl at gmail.com>
> Date: Mon, 19 May 2014 20:47:04 -0700
>
> java.*, javax.*, com.sun.source.* and yes, Taglet, are all OK.
> Joe has now annotated the acceptable APIs with @jdk.Exported
>
> Anything beginning com.sun.tools. (except Taglet) is risky.
>
> Apart from the risk of the API becoming hidden, there is (obviously) no 
> guarantee as to the stability of the internal APIs during JDK 9 
> development, or for consistency between 8 and 9.
>
> -- Jon
>
> On 05/19/2014 08:27 PM, Werner Dietl wrote:
>> Hi Jon,
>>
>> access to javac internals at the moment is unfortunately necessary to
>> implement some functionality.
>> I do realize that such access might go away or break any moment.
>>
>> In general the Checker Framework relies on the public APIs as much as
>> possible. Out of curiosity, I've done some grep, sort, uniq and came
>> up with the import numbers below. There might be a few fully-qualified
>> accesses, but I guess not too many.
>>
>> The one that surprised me was "import com.sun.tools.classfile"; I use
>> that in a test case only to make sure type annotations are written to
>> a classfile.
>>
>> Please do let me know if you want me to look into any particular uses.
>>
>> Cheers,
>> cu, WMD.
>>
>>        6 import com.sun.source.tree.AnnotatedTypeTree;
>>        7 import com.sun.source.tree.AnnotationTree;
>>       12 import com.sun.source.tree.ArrayAccessTree;
>>        4 import com.sun.source.tree.ArrayTypeTree;
>>        5 import com.sun.source.tree.AssertTree;
>>       13 import com.sun.source.tree.AssignmentTree;
>>       22 import com.sun.source.tree.BinaryTree;
>>        8 import com.sun.source.tree.BlockTree;
>>        2 import com.sun.source.tree.BreakTree;
>>        4 import com.sun.source.tree.CaseTree;
>>        2 import com.sun.source.tree.CatchTree;
>>       35 import com.sun.source.tree.ClassTree;
>>       16 import com.sun.source.tree.CompilationUnitTree;
>>       17 import com.sun.source.tree.CompoundAssignmentTree;
>>        8 import com.sun.source.tree.ConditionalExpressionTree;
>>        2 import com.sun.source.tree.ContinueTree;
>>        3 import com.sun.source.tree.DoWhileLoopTree;
>>        2 import com.sun.source.tree.EmptyStatementTree;
>>        6 import com.sun.source.tree.EnhancedForLoopTree;
>>        2 import com.sun.source.tree.ErroneousTree;
>>        4 import com.sun.source.tree.ExpressionStatementTree;
>>       48 import com.sun.source.tree.ExpressionTree;
>>        3 import com.sun.source.tree.ForLoopTree;
>>       24 import com.sun.source.tree.IdentifierTree;
>>        6 import com.sun.source.tree.IfTree;
>>        1 import com.sun.source.tree.ImportTree;
>>        7 import com.sun.source.tree.InstanceOfTree;
>>        2 import com.sun.source.tree.LabeledStatementTree;
>>        2 import com.sun.source.tree.LambdaExpressionTree;
>>        1 import com.sun.source.tree.LineMap;
>>       31 import com.sun.source.tree.LiteralTree;
>>        2 import com.sun.source.tree.MemberReferenceTree;
>>       27 import com.sun.source.tree.MemberSelectTree;
>>       41 import com.sun.source.tree.MethodInvocationTree;
>>       35 import com.sun.source.tree.MethodTree;
>>        4 import com.sun.source.tree.ModifiersTree;
>>       15 import com.sun.source.tree.NewArrayTree;
>>       23 import com.sun.source.tree.NewClassTree;
>>        7 import com.sun.source.tree.ParameterizedTypeTree;
>>        6 import com.sun.source.tree.ParenthesizedTree;
>>        4 import com.sun.source.tree.PrimitiveTypeTree;
>>       11 import com.sun.source.tree.ReturnTree;
>>        1 import com.sun.source.tree.Scope;
>>        6 import com.sun.source.tree.StatementTree;
>>        4 import com.sun.source.tree.SwitchTree;
>>        3 import com.sun.source.tree.SynchronizedTree;
>>        5 import com.sun.source.tree.ThrowTree;
>>      146 import com.sun.source.tree.Tree;
>>       45 import com.sun.source.tree.Tree.Kind;
>>        2 import com.sun.source.tree.TryTree;
>>       15 import com.sun.source.tree.TypeCastTree;
>>        7 import com.sun.source.tree.TypeParameterTree;
>>       12 import com.sun.source.tree.UnaryTree;
>>        2 import com.sun.source.tree.UnionTypeTree;
>>       30 import com.sun.source.tree.VariableTree;
>>        3 import com.sun.source.tree.WhileLoopTree;
>>        3 import com.sun.source.tree.WildcardTree;
>>        2 import com.sun.source.util.JavacTask;
>>        6 import com.sun.source.util.SimpleTreeVisitor;
>>        2 import com.sun.source.util.SourcePositions;
>>        1 import com.sun.source.util.TaskEvent;
>>        1 import com.sun.source.util.TaskListener;
>>       28 import com.sun.source.util.TreePath;
>>        5 import com.sun.source.util.TreePathScanner;
>>       11 import com.sun.source.util.Trees;
>>        2 import com.sun.source.util.TreeScanner;
>>        1 import com.sun.tools.classfile.Attribute;
>>        2 import com.sun.tools.classfile.ClassFile;
>>        1 import com.sun.tools.classfile.Code_attribute;
>>        1 import com.sun.tools.classfile.ConstantPool.InvalidIndex;
>>        1 import com.sun.tools.classfile.ConstantPool.UnexpectedEntry;
>>        1 import com.sun.tools.classfile.Field;
>>        1 import com.sun.tools.classfile.Method;
>>        1 import 
>> com.sun.tools.classfile.RuntimeTypeAnnotations_attribute;
>>        2 import com.sun.tools.classfile.TypeAnnotation;
>>        1 import com.sun.tools.classfile.TypeAnnotation.TargetType;
>>        1 import com.sun.tools.doclets.Taglet;
>>        3 import com.sun.tools.javac.api.JavacScope;
>>        1 import com.sun.tools.javac.api.JavacTool;
>>        1 import com.sun.tools.javac.code.*;
>>        4 import com.sun.tools.javac.code.Attribute;
>>        4 import com.sun.tools.javac.code.Attribute.TypeCompound;
>>        1 import com.sun.tools.javac.code.BoundKind;
>>        3 import com.sun.tools.javac.code.Flags;
>>       13 import com.sun.tools.javac.code.Symbol;
>>        2 import com.sun.tools.javac.code.Symbol.*;
>>        2 import com.sun.tools.javac.code.Symbol.ClassSymbol;
>>        6 import com.sun.tools.javac.code.Symbol.MethodSymbol;
>>        2 import com.sun.tools.javac.code.Symbol.TypeSymbol;
>>        3 import com.sun.tools.javac.code.Symbol.VarSymbol;
>>        1 import com.sun.tools.javac.code.Symtab;
>>        2 import com.sun.tools.javac.code.TargetType;
>>       13 import com.sun.tools.javac.code.Type;
>>        3 import com.sun.tools.javac.code.TypeAnnotationPosition;
>>        2 import 
>> com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry;
>>        2 import 
>> com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntryKind;
>>        1 import com.sun.tools.javac.code.Type.ClassType;
>>        1 import com.sun.tools.javac.code.Types;
>>        1 import com.sun.tools.javac.code.TypeTag;
>>        1 import com.sun.tools.javac.code.Type.WildcardType;
>>        1 import com.sun.tools.javac.comp.*;
>>        2 import com.sun.tools.javac.comp.AttrContext;
>>        1 import com.sun.tools.javac.comp.CompileStates.CompileState;
>>        1 import com.sun.tools.javac.comp.DeferredAttr;
>>        2 import com.sun.tools.javac.comp.Env;
>>        2 import com.sun.tools.javac.comp.Resolve;
>>        2 import com.sun.tools.javac.file.JavacFileManager;
>>        2 import com.sun.tools.javac.main.JavaCompiler;
>>        1 import com.sun.tools.javac.model.JavacElements;
>>        1 import com.sun.tools.javac.model.JavacTypes;
>>       15 import 
>> com.sun.tools.javac.processing.JavacProcessingEnvironment;
>>        9 import com.sun.tools.javac.tree.JCTree;
>>        1 import com.sun.tools.javac.tree.JCTree.JCAnnotatedType;
>>        2 import com.sun.tools.javac.tree.JCTree.JCAnnotation;
>>        1 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
>>        2 import com.sun.tools.javac.tree.JCTree.JCExpression;
>>        1 import com.sun.tools.javac.tree.JCTree.JCExpressionStatement;
>>        1 import com.sun.tools.javac.tree.JCTree.JCLambda;
>>        1 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
>>        2 import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
>>        2 import com.sun.tools.javac.tree.JCTree.JCNewArray;
>>        2 import com.sun.tools.javac.tree.JCTree.JCNewClass;
>>        1 import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
>>        1 import com.sun.tools.javac.tree.Pretty;
>>        3 import com.sun.tools.javac.tree.TreeInfo;
>>        3 import com.sun.tools.javac.tree.TreeMaker;
>>        1 import com.sun.tools.javac.tree.TreeScanner;
>>        1 import com.sun.tools.javac.util.*;
>>       15 import com.sun.tools.javac.util.Context;
>>        8 import com.sun.tools.javac.util.List;
>>        2 import com.sun.tools.javac.util.ListBuffer;
>>        4 import com.sun.tools.javac.util.Log;
>>        3 import com.sun.tools.javac.util.Name;
>>        4 import com.sun.tools.javac.util.Names;
>>        2 import com.sun.tools.javac.util.Pair;
>>        1 import javax.annotation.meta.When;
>>       18 import javax.annotation.Nullable;
>>        5 import javax.annotation.processing.*;
>>        3 import javax.annotation.processing.AbstractProcessor;
>>        1 import javax.annotation.processing.Messager;
>>       38 import javax.annotation.processing.ProcessingEnvironment;
>>        1 import javax.annotation.processing.Processor;
>>        1 import javax.annotation.processing.RoundEnvironment;
>>        3 import javax.annotation.processing.SupportedAnnotationTypes;
>>        8 import javax.annotation.processing.SupportedOptions;
>>        3 import javax.annotation.processing.SupportedSourceVersion;
>>        4 import javax.lang.model.element.*;
>>       79 import javax.lang.model.element.AnnotationMirror;
>>        6 import javax.lang.model.element.AnnotationValue;
>>        2 import javax.lang.model.element.AnnotationValueVisitor;
>>       65 import javax.lang.model.element.Element;
>>       28 import javax.lang.model.element.ElementKind;
>>       48 import javax.lang.model.element.ExecutableElement;
>>       12 import javax.lang.model.element.Modifier;
>>       26 import javax.lang.model.element.Name;
>>        5 import javax.lang.model.element.PackageElement;
>>       39 import javax.lang.model.element.TypeElement;
>>        6 import javax.lang.model.element.TypeParameterElement;
>>       40 import javax.lang.model.element.VariableElement;
>>       11 import javax.lang.model.SourceVersion;
>>        4 import javax.lang.model.type.*;
>>       10 import javax.lang.model.type.ArrayType;
>>       18 import javax.lang.model.type.DeclaredType;
>>        2 import javax.lang.model.type.ExecutableType;
>>        1 import javax.lang.model.type.IntersectionType;
>>        1 import javax.lang.model.type.MirroredTypeException;
>>        1 import javax.lang.model.type.NoType;
>>        2 import javax.lang.model.type.NullType;
>>        5 import javax.lang.model.type.PrimitiveType;
>>        1 import javax.lang.model.type.ReferenceType;
>>       51 import javax.lang.model.type.TypeKind;
>>       53 import javax.lang.model.type.TypeMirror;
>>       12 import javax.lang.model.type.TypeVariable;
>>        2 import javax.lang.model.type.UnionType;
>>        5 import javax.lang.model.type.WildcardType;
>>        2 import javax.lang.model.util.*;
>>        1 import javax.lang.model.util.AbstractElementVisitor6;
>>       14 import javax.lang.model.util.ElementFilter;
>>       23 import javax.lang.model.util.Elements;
>>        1 import javax.lang.model.util.SimpleElementVisitor7;
>>        1 import javax.lang.model.util.SimpleTypeVisitor7;
>>       22 import javax.lang.model.util.Types;
>>        6 import javax.tools.Diagnostic;
>>        2 import javax.tools.DiagnosticCollector;
>>        7 import javax.tools.Diagnostic.Kind;
>>        2 import javax.tools.JavaCompiler;
>>        1 import javax.tools.JavaFileManager;
>>        8 import javax.tools.JavaFileObject;
>>        2 import javax.tools.StandardJavaFileManager;
>>        2 import javax.tools.ToolProvider;
>>        1 import javax.validation.constraints.NotNull;
>>        1 import static com.sun.source.tree.Tree.Kind.NULL_LITERAL;
>>        1 import static com.sun.source.tree.Tree.Kind.STRING_LITERAL;
>>        4 import static 
>> com.sun.tools.classfile.TypeAnnotation.TargetType.*;
>>        1 import static com.sun.tools.javac.code.Flags.ABSTRACT;
>>        1 import static com.sun.tools.javac.code.Flags.EFFECTIVELY_FINAL;
>>        1 import static com.sun.tools.javac.code.Flags.FINAL;
>>        1 import static com.sun.tools.javac.code.Kinds.*;
>>        1 import static com.sun.tools.javac.code.Kinds.VAR;
>>        1 import static com.sun.tools.javac.code.TypeTag.CLASS;
>>        1 import static javax.lang.model.util.ElementFilter.methodsIn;
>>
>>
>> On Mon, May 19, 2014 at 7:49 PM, Jonathan Gibbons
>> <jonathan.gibbons at oracle.com> wrote:
>>> On 05/19/2014 02:17 PM, Werner Dietl wrote:
>>>>>> In type-annotations, I made sure that the BasicAnnoTest at:
>>>>>> test/tools/javac/processing/model/type/BasicAnnoTests.java
>>>>>> compiles correctly.
>>>>>> However, the generics/arrays/exceptions test cases at the end do not
>>>>>> work yet.
>>>>>> Is this something you are aware of? I thought one reason for your
>>>>>> refactorings was exactly to make these tests work.
>>>>> It seems that DPrinter has gotten out of date, due to a few fixes 
>>>>> that
>>>>> have changed the internal data structures.  Among these are a fix 
>>>>> that
>>>>> refactors the top-level nodes, and my fix that eliminates 
>>>>> AnnotatedType.
>>>>>
>>>>> If you've fixed all (or even some) of these issues, I'll gladly
>>>>> integrate your changes.
>>>> The type-annotations repo contains a fixed DPrinter and I've kept it
>>>> up-to-date through all recent refactorings.
>>>>
>>>> I haven't fixed the BasicAnnoTests, as my understanding was that
>>>> fixing these tests is one reason for your refactorings.
>>>>
>>>>
>>>>>> Another difference that would make compatibility between jdk8 and 
>>>>>> jkd9
>>>>>> easier is if field "exception_index" remained public to allow direct
>>>>>> access.
>>>>> Unfortunately, I think that's less feasible.  The exception_index 
>>>>> field
>>>>> currently gets used to store both exception indexes, as well as a
>>>>> combination of catch info and source positions.  Because the 
>>>>> formatting
>>>>> for this is nontrivial, and we have plans to eliminate it in the 
>>>>> future,
>>>>> exception_index was made private and accessible through getters and
>>>>> setters.
>>>>>
>>>>> I would, however, be willing to add an updateExceptionIndex, which 
>>>>> would
>>>>> allow you to change the index after it has already been set.
>>>> I have two use cases: create a new TAP from an existing TAP and
>>>> comparing two TAPs for equality.
>>>> For either one, I don't care what the underlying interpretation of the
>>>> ints is, I just need to copy/compare them.
>>>>
>>>> One of our goals is to keep the Checker Framework running with the
>>>> standard Java 8 compiler. I already perform quite a few TAP things
>>>> reflectively to achieve this. I can do the same with the
>>>> exception_index field, its just yet another complication that gets
>>>> introduced.
>>>>
>>>>
>>>>>> A few tests in jdk9 are disabled, even though they pass in
>>>>>> type-annotations.
>>>>>> The other differences between jdk9 and type-annotations are small
>>>>>> fixes to javadoc, performance, and imports.
>>>>>> See my message from May 8 for details:
>>>>>>
>>>>>> http://mail.openjdk.java.net/pipermail/type-annotations-dev/2014-May/001722.html
>>>>> More tests are being re-enabled in the cleanup patch.  I am currently
>>>>> looking into the javadoc tests as well.  As for the other fixes, I 
>>>>> think
>>>>> I would like to get the two big patches (the rearchitecting patch and
>>>>> the cleanup patch) integrated, then look at them one-by-one.
>>>> Ok, please do let me know if I can help.
>>>> I would like to get all useful changes from type-annotations into jdk9
>>>> so that we can ideally close type-annotations in a state that exactly
>>>> matches jdk9.
>>>>
>>>> Thanks,
>>>> cu, WMD.
>>>>
>>>
>>> Werner,
>>>
>>> Can you clarify how much Checker Framework uses javac internal API
>>> and how much it just relies on public/supported API like java.*, 
>>> javax.*
>>> and com.sun.source.*?
>>>
>>> Going forward, you should not assume you will have direct access to
>>> javac internals forever.
>>>
>>> -- Jon
>>
>


More information about the type-annotations-dev mailing list