180 String message = "JAVAC MESSAGE FILE IS BROKEN: key={0}, arguments={1}, {2}, {3}";
181 return MessageFormat.format(message, key, fixed1, fixed2, fixed3);
182 }
183 }
184
185 // What major and minor version numbers to use for the -target flag.
186 // This should grow every time the minor version number accepted by
187 // the VM is incremented.
188 private static final String[] releases = { "1.1", "1.2", "1.3", "1.4" };
189 private static final short[] majorVersions = { 45, 46, 47, 48 };
190 private static final short[] minorVersions = { 3, 0, 0, 0 };
191
192 /**
193 * Run the compiler
194 */
195 @SuppressWarnings("fallthrough")
196 public synchronized boolean compile(String argv[]) {
197 String sourcePathArg = null;
198 String classPathArg = null;
199 String sysClassPathArg = null;
200 String extDirsArg = null;
201 boolean verbosePath = false;
202
203 String targetArg = null;
204 short majorVersion = JAVA_DEFAULT_VERSION;
205 short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
206
207 File destDir = null;
208 //JCOV
209 File covFile = null;
210 String optJcov = "-Xjcov";
211 String optJcovFile = "-Xjcov:file=";
212 //end JCOV
213 int flags = F_WARNINGS | F_DEBUG_LINES | F_DEBUG_SOURCE;
214 long tm = System.currentTimeMillis();
215 Vector<String> v = new Vector<>();
216 boolean nowrite = false;
217 String props = null;
218 String encoding = null;
219
220 // These flags are used to make sure conflicting -O and -g
325 if (sysClassPathArg != null) {
326 error("main.option.already.seen","-sysclasspath");
327 }
328 sysClassPathArg = argv[++i];
329 } else {
330 error("main.option.requires.argument","-sysclasspath");
331 usage_error();
332 return false; // Stop processing now
333 }
334 } else if (argv[i].equals("-bootclasspath")) {
335 if ((i + 1) < argv.length) {
336 if (sysClassPathArg != null) {
337 error("main.option.already.seen","-bootclasspath");
338 }
339 sysClassPathArg = argv[++i];
340 } else {
341 error("main.option.requires.argument","-bootclasspath");
342 usage_error();
343 return false; // Stop processing now
344 }
345 } else if (argv[i].equals("-extdirs")) {
346 if ((i + 1) < argv.length) {
347 if (extDirsArg != null) {
348 error("main.option.already.seen","-extdirs");
349 }
350 extDirsArg = argv[++i];
351 } else {
352 error("main.option.requires.argument","-extdirs");
353 usage_error();
354 return false; // Stop processing now
355 }
356 } else if (argv[i].equals("-encoding")) {
357 if ((i + 1) < argv.length) {
358 if (encoding!=null)
359 error("main.option.already.seen","-encoding");
360 encoding = argv[++i];
361 } else {
362 error("main.option.requires.argument","-encoding");
363 usage_error();
364 return false; // Stop processing now
365 }
366 } else if (argv[i].equals("-target")) {
367 if ((i + 1) < argv.length) {
368 if (targetArg!=null)
369 error("main.option.already.seen","-target");
370 targetArg = argv[++i];
371 int j;
372 for (j=0; j<releases.length; j++) {
373 if (releases[j].equals(targetArg)) {
374 majorVersion = majorVersions[j];
375 minorVersion = minorVersions[j];
458 // for the sake of stability. These options will
459 // be merged in a future release.
460 flags |= F_VERSION12;
461 } else if (argv[i].endsWith(".java")) {
462 v.addElement(argv[i]);
463 } else {
464 error("main.no.such.option",argv[i]);
465 usage_error();
466 return false; // Stop processing now
467 }
468 }
469 if (v.size() == 0 || exitStatus == EXIT_CMDERR) {
470 usage_error();
471 return false;
472 }
473
474 // Create our Environment.
475 BatchEnvironment env = BatchEnvironment.create(out,
476 sourcePathArg,
477 classPathArg,
478 sysClassPathArg,
479 extDirsArg);
480 if (verbosePath) {
481 output(getText("main.path.msg",
482 env.sourcePath.toString(),
483 env.binaryPath.toString()));
484 }
485
486 env.flags |= flags;
487 env.majorVersion = majorVersion;
488 env.minorVersion = minorVersion;
489 // JCOV
490 env.covFile = covFile;
491 // end JCOV
492 env.setCharacterEncoding(encoding);
493
494 // Preload the "out of memory" error string just in case we run
495 // out of memory during the compile.
496 String noMemoryErrorString = getText("main.no.memory");
497 String stackOverflowErrorString = getText("main.stack.overflow");
498
499 env.error(0, "warn.class.is.deprecated", "sun.tools.javac.Main");
500
501 try {
502 // Parse all input files
503 for (Enumeration<String> e = v.elements() ; e.hasMoreElements() ;) {
504 File file = new File(e.nextElement());
505 try {
506 env.parseFile(new ClassFile(file));
507 } catch (FileNotFoundException ee) {
508 env.error(0, "cant.read", file.getPath());
509 exitStatus = EXIT_CMDERR;
510 }
511 }
512
513 // Do a post-read check on all newly-parsed classes,
514 // after they have all been read.
515 for (Enumeration<ClassDeclaration> e = env.getClasses() ; e.hasMoreElements() ; ) {
516 ClassDeclaration c = e.nextElement();
517 if (c.getStatus() == CS_PARSED) {
518 if (c.getClassDefinition().isLocal())
519 continue;
520 try {
521 c.getClassDefinition(env);
522 } catch (ClassNotFound ee) {
523 }
524 }
525 }
526
|
180 String message = "JAVAC MESSAGE FILE IS BROKEN: key={0}, arguments={1}, {2}, {3}";
181 return MessageFormat.format(message, key, fixed1, fixed2, fixed3);
182 }
183 }
184
185 // What major and minor version numbers to use for the -target flag.
186 // This should grow every time the minor version number accepted by
187 // the VM is incremented.
188 private static final String[] releases = { "1.1", "1.2", "1.3", "1.4" };
189 private static final short[] majorVersions = { 45, 46, 47, 48 };
190 private static final short[] minorVersions = { 3, 0, 0, 0 };
191
192 /**
193 * Run the compiler
194 */
195 @SuppressWarnings("fallthrough")
196 public synchronized boolean compile(String argv[]) {
197 String sourcePathArg = null;
198 String classPathArg = null;
199 String sysClassPathArg = null;
200 boolean verbosePath = false;
201
202 String targetArg = null;
203 short majorVersion = JAVA_DEFAULT_VERSION;
204 short minorVersion = JAVA_DEFAULT_MINOR_VERSION;
205
206 File destDir = null;
207 //JCOV
208 File covFile = null;
209 String optJcov = "-Xjcov";
210 String optJcovFile = "-Xjcov:file=";
211 //end JCOV
212 int flags = F_WARNINGS | F_DEBUG_LINES | F_DEBUG_SOURCE;
213 long tm = System.currentTimeMillis();
214 Vector<String> v = new Vector<>();
215 boolean nowrite = false;
216 String props = null;
217 String encoding = null;
218
219 // These flags are used to make sure conflicting -O and -g
324 if (sysClassPathArg != null) {
325 error("main.option.already.seen","-sysclasspath");
326 }
327 sysClassPathArg = argv[++i];
328 } else {
329 error("main.option.requires.argument","-sysclasspath");
330 usage_error();
331 return false; // Stop processing now
332 }
333 } else if (argv[i].equals("-bootclasspath")) {
334 if ((i + 1) < argv.length) {
335 if (sysClassPathArg != null) {
336 error("main.option.already.seen","-bootclasspath");
337 }
338 sysClassPathArg = argv[++i];
339 } else {
340 error("main.option.requires.argument","-bootclasspath");
341 usage_error();
342 return false; // Stop processing now
343 }
344 } else if (argv[i].equals("-encoding")) {
345 if ((i + 1) < argv.length) {
346 if (encoding!=null)
347 error("main.option.already.seen","-encoding");
348 encoding = argv[++i];
349 } else {
350 error("main.option.requires.argument","-encoding");
351 usage_error();
352 return false; // Stop processing now
353 }
354 } else if (argv[i].equals("-target")) {
355 if ((i + 1) < argv.length) {
356 if (targetArg!=null)
357 error("main.option.already.seen","-target");
358 targetArg = argv[++i];
359 int j;
360 for (j=0; j<releases.length; j++) {
361 if (releases[j].equals(targetArg)) {
362 majorVersion = majorVersions[j];
363 minorVersion = minorVersions[j];
446 // for the sake of stability. These options will
447 // be merged in a future release.
448 flags |= F_VERSION12;
449 } else if (argv[i].endsWith(".java")) {
450 v.addElement(argv[i]);
451 } else {
452 error("main.no.such.option",argv[i]);
453 usage_error();
454 return false; // Stop processing now
455 }
456 }
457 if (v.size() == 0 || exitStatus == EXIT_CMDERR) {
458 usage_error();
459 return false;
460 }
461
462 // Create our Environment.
463 BatchEnvironment env = BatchEnvironment.create(out,
464 sourcePathArg,
465 classPathArg,
466 sysClassPathArg);
467 if (verbosePath) {
468 output(getText("main.path.msg",
469 env.sourcePath.toString(),
470 env.binaryPath.toString()));
471 }
472
473 env.flags |= flags;
474 env.majorVersion = majorVersion;
475 env.minorVersion = minorVersion;
476 // JCOV
477 env.covFile = covFile;
478 // end JCOV
479 env.setCharacterEncoding(encoding);
480
481 // Preload the "out of memory" error string just in case we run
482 // out of memory during the compile.
483 String noMemoryErrorString = getText("main.no.memory");
484 String stackOverflowErrorString = getText("main.stack.overflow");
485
486 env.error(0, "warn.class.is.deprecated", "sun.tools.javac.Main");
487
488 try {
489 // Parse all input files
490 for (Enumeration<String> e = v.elements() ; e.hasMoreElements() ;) {
491 File file = new File(e.nextElement());
492 try {
493 env.parseFile(ClassFile.newClassFile(file));
494 } catch (FileNotFoundException ee) {
495 env.error(0, "cant.read", file.getPath());
496 exitStatus = EXIT_CMDERR;
497 }
498 }
499
500 // Do a post-read check on all newly-parsed classes,
501 // after they have all been read.
502 for (Enumeration<ClassDeclaration> e = env.getClasses() ; e.hasMoreElements() ; ) {
503 ClassDeclaration c = e.nextElement();
504 if (c.getStatus() == CS_PARSED) {
505 if (c.getClassDefinition().isLocal())
506 continue;
507 try {
508 c.getClassDefinition(env);
509 } catch (ClassNotFound ee) {
510 }
511 }
512 }
513
|