485 public CompileState shouldStopPolicy; |
485 public CompileState shouldStopPolicy; |
486 |
486 |
487 /** A queue of all as yet unattributed classes. |
487 /** A queue of all as yet unattributed classes. |
488 */ |
488 */ |
489 public Todo todo; |
489 public Todo todo; |
|
490 |
|
491 /** A list of items to be closed when the compilation is complete. |
|
492 */ |
|
493 public List<Closeable> closeables = List.nil(); |
490 |
494 |
491 /** Ordered list of compiler phases for each compilation unit. */ |
495 /** Ordered list of compiler phases for each compilation unit. */ |
492 public enum CompileState { |
496 public enum CompileState { |
493 PARSE(1), |
497 PARSE(1), |
494 ENTER(2), |
498 ENTER(2), |
1579 throw new Abort(e); |
1583 throw new Abort(e); |
1580 } finally { |
1584 } finally { |
1581 if (names != null && disposeNames) |
1585 if (names != null && disposeNames) |
1582 names.dispose(); |
1586 names.dispose(); |
1583 names = null; |
1587 names = null; |
|
1588 |
|
1589 for (Closeable c: closeables) { |
|
1590 try { |
|
1591 c.close(); |
|
1592 } catch (IOException e) { |
|
1593 // When javac uses JDK 7 as a baseline, this code would be |
|
1594 // better written to set any/all exceptions from all the |
|
1595 // Closeables as suppressed exceptions on the FatalError |
|
1596 // that is thrown. |
|
1597 JCDiagnostic msg = diagFactory.fragment("fatal.err.cant.close"); |
|
1598 throw new FatalError(msg, e); |
|
1599 } |
|
1600 } |
1584 } |
1601 } |
1585 } |
1602 } |
1586 |
1603 |
1587 protected void printNote(String lines) { |
1604 protected void printNote(String lines) { |
1588 Log.printLines(log.noticeWriter, lines); |
1605 Log.printLines(log.noticeWriter, lines); |
1613 public void initRound(JavaCompiler prev) { |
1630 public void initRound(JavaCompiler prev) { |
1614 genEndPos = prev.genEndPos; |
1631 genEndPos = prev.genEndPos; |
1615 keepComments = prev.keepComments; |
1632 keepComments = prev.keepComments; |
1616 start_msec = prev.start_msec; |
1633 start_msec = prev.start_msec; |
1617 hasBeenUsed = true; |
1634 hasBeenUsed = true; |
|
1635 closeables = prev.closeables; |
|
1636 prev.closeables = List.nil(); |
1618 } |
1637 } |
1619 |
1638 |
1620 public static void enableLogging() { |
1639 public static void enableLogging() { |
1621 Logger logger = Logger.getLogger(com.sun.tools.javac.Main.class.getPackage().getName()); |
1640 Logger logger = Logger.getLogger(com.sun.tools.javac.Main.class.getPackage().getName()); |
1622 logger.setLevel(Level.ALL); |
1641 logger.setLevel(Level.ALL); |