lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawid Weiss <dawid.we...@gmail.com>
Subject Detecting sysouts/syserrs.
Date Wed, 21 Mar 2012 23:11:50 GMT
JIRA is down and I'm off to bed so for the record -- I did try the
aspectj based sysout/syserr tracking. Dead simple and I think nice
(although requires the humongous aspectj JARs :)

I applied that aspect just to see what happens.
{noformat}
ajc -sourceroots aspects \
    -inpath lucene-core-3.6-SNAPSHOT.jar \
    -d none \
    -cp aspectjrt.jar \
    -showWeaveInfo
{noformat}
Here's what I got:
{noformat}
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.analysis.PorterStemmer'
(PorterStemmer.java:529) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.analysis.PorterStemmer'
(PorterStemmer.java:534) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.analysis.PorterStemmer'
(PorterStemmer.java:542) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:989)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:996)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1003)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1012)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1013)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1038)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1043)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1047)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1056)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1057)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1062)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1071)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1073)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1074)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1077)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1079)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1081)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1082)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.CheckIndex' (CheckIndex.java:1085)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:55)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:56)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:57)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:58)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:59)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:60)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:61)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:62)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:65)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:81)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:86)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.queryParser.FastCharStream'
(FastCharStream.java:102) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.queryParser.QueryParser'
(QueryParser.java:1159) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.queryParser.QueryParser'
(QueryParser.java:1165) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.queryParser.QueryParserTokenManager'
(QueryParserTokenManager.java:42) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockStressTest' (LockStressTest.java:37)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockStressTest' (LockStressTest.java:58)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockStressTest'
(LockStressTest.java:100) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockStressTest'
(LockStressTest.java:104) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockVerifyServer'
(LockVerifyServer.java:45) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockVerifyServer'
(LockVerifyServer.java:53) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockVerifyServer'
(LockVerifyServer.java:72) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockVerifyServer'
(LockVerifyServer.java:78) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.store.LockVerifyServer'
(LockVerifyServer.java:84) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:6)
{noformat}
Many of these are in static main methods and here's where
aspectj-based solution can be superior to handcoding; because we can
do this:
{code}
    pointcut ignored():
        withincode(public static void main(String[]));

    before(): within(org.apache.lucene..*) &&
              get(static PrintStream System.*) &&
              !ignored()
    {
        throw new RuntimeException("Attempted sysout/syserr/sysin access.");
    }
{code}
applied again:
{noformat}
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:55)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:56)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:57)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:58)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:59)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:60)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:61)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:62)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.index.IndexUpgrader' (IndexUpgrader.java:65)
advised by before advice from 'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.queryParser.FastCharStream'
(FastCharStream.java:102) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:16)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.queryParser.QueryParserTokenManager'
(QueryParserTokenManager.java:42) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:16)
{noformat}	
IndexUpgrader has a printUsage() method so we can exclude these by
name only (no access/ static restriction):
{code}
    pointcut ignored():
        withincode(public static void main(String[])) ||
        withincode(              void printUsage(..));
{code}
and then we're left with:
{noformat}
Join point 'field-get(java.io.PrintStream java.lang.System.err)' in
Type 'org.apache.lucene.queryParser.FastCharStream'
(FastCharStream.java:102) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:17)
	
Join point 'field-get(java.io.PrintStream java.lang.System.out)' in
Type 'org.apache.lucene.queryParser.QueryParserTokenManager'
(QueryParserTokenManager.java:42) advised by before advice from
'spikes.NoSysOuts' (NoSysOuts.aj:17)
{noformat}
and these are:
{code}
    } catch (IOException e) {
      System.err.println("Caught: " + e + "; ignoring.");
    }
{code}
and:
{code}
  /** Debug output. */
  public  java.io.PrintStream debugStream = System.out;
{code}
This is perhaps the worst cast as it assigns System.out to another
field and then uses that to call printlns.

Both of which can be excluded, of course. AspectJ is fun. It's a pity
it never gained more traction.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


Mime
View raw message