/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6877202 6986246
* @summary Elements.getDocComment() is not getting JavaDocComments
*/
/*
* For a mixture of pre-existing and generated source files, ensure that we can
* get the doc comments.
* The test uses both a standard ElementScanner to find all the elements being
* processed, and a TreeScanner to find all the local and anonymous inner classes
* as well.
* And, because the relevant code paths in the compiler are different for
* command line and JSR 199 invocation, the test covers both ways of invoking the
* compiler.
*/
@SupportedOptions("scan")
@SupportedAnnotationTypes("*")
// ----- Main test driver: invoke compiler for the various test cases ------
try {
} catch (IOException e) {
}
}
}
if (errors > 0)
}
"-implicit:none",
"-processorpath", testClasses,
//"-XprintRounds",
"-Ascan=" + sk
};
};
else
}
}
};
t.parse();
t.analyze();
}
if (rc > 0)
}
errors++;
//throw new Error(msg);
}
static int errors;
// ----- Annotation processor: scan for elements and check doc comments ----
return SourceVersion.latest();
}
}
round++;
// Scan elements using an appropriate scanner, and for each element found,
// call check(Element e) to verify the doc comment on that element
} else
new TestElementScanner().scan(e);
}
// For a few rounds, generate new source files, so that we can check whether
// doc comments are correctly handled in subsequent processing rounds
final int MAX_ROUNDS = 3;
if (round <= MAX_ROUNDS) {
try {
try {
} finally {
}
} catch (IOException e) {
throw new Error(e);
}
}
return true;
}
/*
* Check that the doc comment on an element is as expected.
* This method is invoked for each element found by the scanners run by process.
*/
switch (e.getKind()) {
case PARAMETER:
case LOCAL_VARIABLE:
// doc comments not retained for these elements
break;
case CONSTRUCTOR:
// Enum constructor is synthetic
}
break;
case METHOD:
// synthetic enum methods
}
break;
case CLASS:
// anon inner class
}
break;
}
return;
else {
}
}
// ----- Scanners to find elements -----------------------------------------
check(e);
return super.visitExecutable(e, _);
}
check(e);
return super.visitType(e, _);
}
check(e);
return super.visitVariable(e, _);
}
}
}
}
}
}
}