Skip to content

Commit 94e2e90

Browse files
committed
8229388: ErrorHandler and ContentHandler contain ambiguous/unfinished specification
Reviewed-by: lancea
1 parent 3ba89c3 commit 94e2e90

File tree

2 files changed

+30
-36
lines changed

2 files changed

+30
-36
lines changed

src/java.xml/share/classes/org/xml/sax/ContentHandler.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -130,19 +130,15 @@ public void startDocument ()
130130
/**
131131
* Receive notification of the end of a document.
132132
*
133-
* <p><strong>There is an apparent contradiction between the
134-
* documentation for this method and the documentation for {@link
135-
* org.xml.sax.ErrorHandler#fatalError}. Until this ambiguity is
136-
* resolved in a future major release, clients should make no
137-
* assumptions about whether endDocument() will or will not be
138-
* invoked when the parser has reported a fatalError() or thrown
139-
* an exception.</strong></p>
140-
*
141-
* <p>The SAX parser will invoke this method only once, and it will
142-
* be the last method invoked during the parse. The parser shall
143-
* not invoke this method until it has either abandoned parsing
144-
* (because of an unrecoverable error) or reached the end of
145-
* input.</p>
133+
* <p>
134+
* This method is invoked by the parser to signal it has reached the end of
135+
* the document after successfully completing the parsing process.
136+
* After the event, the parser will return the control to the application.
137+
*
138+
* @apiNote In case of a fatal error, the parser may choose to stop the
139+
* parsing process with a {@link SAXException}, in which case, this method
140+
* will never be called. Refer to
141+
* {@link ErrorHandler#fatalError(org.xml.sax.SAXParseException)}.
146142
*
147143
* @throws org.xml.sax.SAXException any SAX exception, possibly
148144
* wrapping another exception

src/java.xml/share/classes/org/xml/sax/ErrorHandler.java

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -128,32 +128,30 @@ public abstract void error (SAXParseException exception)
128128

129129

130130
/**
131-
* Receive notification of a non-recoverable error.
131+
* Receive notification of a non-recoverable, fatal error.
132132
*
133-
* <p><strong>There is an apparent contradiction between the
134-
* documentation for this method and the documentation for {@link
135-
* org.xml.sax.ContentHandler#endDocument}. Until this ambiguity
136-
* is resolved in a future major release, clients should make no
137-
* assumptions about whether endDocument() will or will not be
138-
* invoked when the parser has reported a fatalError() or thrown
139-
* an exception.</strong></p>
133+
* <p>
134+
* As defined in section 1.2 of the W3C XML 1.0 Recommendation, fatal errors
135+
* are those that would make it impossible for a parser to continue normal
136+
* processing. These include violation of a well-formedness constraint,
137+
* invalid encoding, and forbidden structural errors as described in the
138+
* W3C XML 1.0 Recommendation.
140139
*
141-
* <p>This corresponds to the definition of "fatal error" in
142-
* section 1.2 of the W3C XML 1.0 Recommendation. For example, a
143-
* parser would use this callback to report the violation of a
144-
* well-formedness constraint.</p>
140+
* @apiNote An application must assume that the parser can no longer perform
141+
* normal processing after reporting a fatal error and may stop by throwing
142+
* a {@link SAXException} without calling {@link ContentHandler#endDocument()}.
143+
* In addition, the parser cannot be expected to be able to return accurate
144+
* information about the logical structure on the rest of the document even
145+
* if it may be able to resume parsing.
145146
*
146-
* <p>The application must assume that the document is unusable
147-
* after the parser has invoked this method, and should continue
148-
* (if at all) only for the sake of collecting additional error
149-
* messages: in fact, SAX parsers are free to stop reporting any
150-
* other events once this method has been invoked.</p>
147+
* @implNote After invoking this method, the parser may stop processing by
148+
* throwing a {@link SAXException}, or implement a feature that can direct
149+
* it to continue after a fatal error. In the later case, it may report
150+
* events on the rest of the document without any guarantee of correctness.
151151
*
152152
* @param exception The error information encapsulated in a
153-
* SAX parse exception.
154-
* @exception org.xml.sax.SAXException Any SAX exception, possibly
155-
* wrapping another exception.
156-
* @see org.xml.sax.SAXParseException
153+
* {@link SAXParseException}.
154+
* @throws SAXException if the application chooses to discontinue the parsing
157155
*/
158156
public abstract void fatalError (SAXParseException exception)
159157
throws SAXException;

0 commit comments

Comments
 (0)