1.1 --- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Sep 27 14:20:39 2010 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Mon Sep 27 17:28:49 2010 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -56,7 +56,6 @@ 1.11 import com.sun.tools.javac.comp.MemberEnter; 1.12 import com.sun.tools.javac.comp.Resolve; 1.13 import com.sun.tools.javac.model.JavacElements; 1.14 -import com.sun.tools.javac.processing.JavacMessager; 1.15 import com.sun.tools.javac.processing.JavacProcessingEnvironment; 1.16 import com.sun.tools.javac.tree.JCTree.*; 1.17 import com.sun.tools.javac.tree.JCTree; 1.18 @@ -81,14 +80,15 @@ 1.19 */ 1.20 public class JavacTrees extends Trees { 1.21 1.22 - private final Resolve resolve; 1.23 - private final Enter enter; 1.24 - private final Log log; 1.25 - private final MemberEnter memberEnter; 1.26 - private final Attr attr; 1.27 - private final TreeMaker treeMaker; 1.28 - private final JavacElements elements; 1.29 - private final JavacTaskImpl javacTaskImpl; 1.30 + // in a world of a single context per compilation, these would all be final 1.31 + private Resolve resolve; 1.32 + private Enter enter; 1.33 + private Log log; 1.34 + private MemberEnter memberEnter; 1.35 + private Attr attr; 1.36 + private TreeMaker treeMaker; 1.37 + private JavacElements elements; 1.38 + private JavacTaskImpl javacTaskImpl; 1.39 1.40 public static JavacTrees instance(JavaCompiler.CompilationTask task) { 1.41 if (!(task instanceof JavacTaskImpl)) 1.42 @@ -111,6 +111,14 @@ 1.43 1.44 private JavacTrees(Context context) { 1.45 context.put(JavacTrees.class, this); 1.46 + init(context); 1.47 + } 1.48 + 1.49 + public void updateContext(Context context) { 1.50 + init(context); 1.51 + } 1.52 + 1.53 + private void init(Context context) { 1.54 attr = Attr.instance(context); 1.55 enter = Enter.instance(context); 1.56 elements = JavacElements.instance(context); 1.57 @@ -337,6 +345,7 @@ 1.58 super(M); 1.59 } 1.60 1.61 + @Override 1.62 public <T extends JCTree> T copy(T t, JCTree leaf) { 1.63 T t2 = super.copy(t, leaf); 1.64 if (t == leaf)