langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java
changeset 20604 13bdd49ddaf0
parent 14957 ea7808ffcf6d
child 25006 5d5fa4abab27
equal deleted inserted replaced
20603:1cba7386cfd9 20604:13bdd49ddaf0
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   118                              Context context)
   118                              Context context)
   119     {
   119     {
   120         try {
   120         try {
   121             ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
   121             ClientCodeWrapper ccw = ClientCodeWrapper.instance(context);
   122 
   122 
   123             final String kindMsg = "All compilation units must be of SOURCE kind";
       
   124             if (options != null)
   123             if (options != null)
   125                 for (String option : options)
   124                 for (String option : options)
   126                     option.getClass(); // null check
   125                     option.getClass(); // null check
   127             if (classes != null) {
   126             if (classes != null) {
   128                 for (String cls : classes)
   127                 for (String cls : classes)
   130                         throw new IllegalArgumentException("Not a valid class name: " + cls);
   129                         throw new IllegalArgumentException("Not a valid class name: " + cls);
   131             }
   130             }
   132             if (compilationUnits != null) {
   131             if (compilationUnits != null) {
   133                 compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
   132                 compilationUnits = ccw.wrapJavaFileObjects(compilationUnits); // implicit null check
   134                 for (JavaFileObject cu : compilationUnits) {
   133                 for (JavaFileObject cu : compilationUnits) {
   135                     if (cu.getKind() != JavaFileObject.Kind.SOURCE)
   134                     if (cu.getKind() != JavaFileObject.Kind.SOURCE) {
       
   135                         String kindMsg = "Compilation unit is not of SOURCE kind: "
       
   136                                 + "\"" + cu.getName() + "\"";
   136                         throw new IllegalArgumentException(kindMsg);
   137                         throw new IllegalArgumentException(kindMsg);
       
   138                     }
   137                 }
   139                 }
   138             }
   140             }
   139 
   141 
   140             if (diagnosticListener != null)
   142             if (diagnosticListener != null)
   141                 context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));
   143                 context.put(DiagnosticListener.class, ccw.wrap(diagnosticListener));