Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx05.eternal-september.org!.POSTED!not-for-mail From: Jeff Higgins Newsgroups: comp.lang.java.programmer Subject: Re: How to scan Java source texts? Date: Wed, 12 Jun 2013 14:38:54 -0400 Organization: A noiseless patient Spider Lines: 27 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 12 Jun 2013 18:32:50 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6b9e92482af47766954d85fb77d372f5"; logging-data="12604"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18f95IXk7JKRj4Q3g1YTw1N7PgJJmrUNMw=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130529 Icedove/17.0.5 In-Reply-To: Cancel-Lock: sha1:fFr9jIUtBZ7mtMtU7QY6Bu40QC0= Xref: csiph.com comp.lang.java.programmer:24390 On 06/12/2013 12:44 PM, Stefan Ram wrote: > Jeff Higgins writes: >> I don't see a way to do what you want using the existing API. > > Thanks for your remarks!, which helped me > to find out that it can be done, once one > is willing to use the »com.sun....«-classes, > such as »Scanner«. »tools.jar« needs to be in > the classpath for this. The only problem I see now is gaining access to the protected Scanner constructor outside of the com.sun.tools.javac.parser package. Maybe I'll try extending my newly built javac to include a -tokenize extension as above. > Now, there indeed is the risk that these classes > will change in future JDK versions. But still > I estimate them to be more stable than some > third-party libraries. For example, for the same > purpose I used a third-party program before that > now has not been adapted to Java >= 1.5, so that I > now needed to find some means to accomplish this > for Java >= 1.5. >