Lucene - Core
  1. Lucene - Core
  2. LUCENE-4199

Add ANT tool to track/disallow "forbidden" method invocations

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 4.0-ALPHA
    • Fix Version/s: 4.0-BETA
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      New

      Description

      In LUCENE-3877 Greg Bowyer has some asm.jar-based code to inspe ct class files for System.out/err class. I wanted to modify this code to run it in a jar-linter task on ant, so all compiled class files are parsed and method/ctor calls to e.g. new String(byte[]) without charset are forbidden. We would add a list of method signatures that we dont want to have (new FileReader(File), commons.IOUtils.loadFileToString()) and this linter will throw BuildException after static inspection, if any class file in Lucene/Solr (including line numbers) uses any method call.

      Greg's code would be changed to use visitMethodInsn visitor, very easy.

      1. LUCENE-4199.patch
        383 kB
        Uwe Schindler
      2. LUCENE-4199.patch
        26 kB
        Uwe Schindler
      3. LUCENE-4199.patch
        20 kB
        Uwe Schindler
      4. LUCENE-4199.patch
        10 kB
        Uwe Schindler

        Issue Links

          Activity

          Hide
          Dawid Weiss added a comment -

          I still think an aspectj pass would be nicer... but I'll live with asm. It would be faster too.

          Show
          Dawid Weiss added a comment - I still think an aspectj pass would be nicer... but I'll live with asm. It would be faster too.
          Hide
          Chris Male added a comment -

          Or we could use PMD or FindBugs.

          Show
          Chris Male added a comment - Or we could use PMD or FindBugs.
          Hide
          Dawid Weiss added a comment -

          They're sooooooo slow

          Show
          Dawid Weiss added a comment - They're sooooooo slow
          Hide
          Chris Male added a comment -

          And aspectj is bloated and asm is inflexible and requires a lot of boilerplate

          Show
          Chris Male added a comment - And aspectj is bloated and asm is inflexible and requires a lot of boilerplate
          Hide
          Robert Muir added a comment -

          This is a good idea!

          Similar to default Charset, there are also trappy methods that use default Locale, i would like to detect these too (there would be some to fix): String.toLowerCase(), etc etc

          Show
          Robert Muir added a comment - This is a good idea! Similar to default Charset, there are also trappy methods that use default Locale, i would like to detect these too (there would be some to fix): String.toLowerCase(), etc etc
          Hide
          Dawid Weiss added a comment -

          And aspectj is bloated and asm is inflexible and requires a lot of boilerplate

          There are pros and cons of every choice, I don't deny it. My experience with pmd/ findbugs is that they're painfully slow. So I'd opt for a custom fast scanner if it were to become part of the regular build pipeline or aspectj if it were to become part of a nightly/ jenkins run. Everybody has his favorite toys

          Show
          Dawid Weiss added a comment - And aspectj is bloated and asm is inflexible and requires a lot of boilerplate There are pros and cons of every choice, I don't deny it. My experience with pmd/ findbugs is that they're painfully slow. So I'd opt for a custom fast scanner if it were to become part of the regular build pipeline or aspectj if it were to become part of a nightly/ jenkins run. Everybody has his favorite toys
          Hide
          Uwe Schindler added a comment -

          If I would not have been outside for ice cream, the non bloated fast version would already have been finished . Working... (one-handed)

          I come back in a microsecond!

          Show
          Uwe Schindler added a comment - If I would not have been outside for ice cream, the non bloated fast version would already have been finished . Working... (one-handed) I come back in a microsecond!
          Hide
          Uwe Schindler added a comment -

          Very rough patch for testing and it already found 75 errors:

          validate2:
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\java\org\apache\lucene\analysis\br\BrazilianStemmer.class, source line 246
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\java\org\apache\lucene\analysis\de\GermanStemmer.class, source line 50
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\sinks\TestTeeSinkTokenFilter.class, source line 167
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\sinks\TestTeeSinkTokenFilter.class, source line 183
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 261
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 308
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 354
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 56
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 73
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 87
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 87
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 101
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 101
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\Compile.class, source line 92
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\Compile.class, source line 130
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\DiffIt.class, source line 101
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 110
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 127
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 135
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 135
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 146
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 146
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\feeds\EnwikiContentSource$Parser.class, source line 149
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\tasks\TaskSequence.class, source line 490
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\utils\Algorithm.class, source line 162
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 40
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 65
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 78
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 97
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 46
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 76
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 99
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 100
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics$SimplePayloadFilter.class, source line 84
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 414
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 429
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 430
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 442
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 443
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 444
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 473
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 474
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 475
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 476
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans$PayloadFilter.class, source line 508
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans$PayloadFilter.class, source line 510
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 279
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 314
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 350
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 386
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 458
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 45
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 54
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 63
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCompactLabelToOrdinal.class, source line 49
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 661
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 662
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 938
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 967
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 1001
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 1021
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 154
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 158
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 163
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 167
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\util\UnescapedCharSequence.class, source line 151
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\util\UnescapedCharSequence.class, source line 155
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 53
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 76
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 181
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\test\org\apache\lucene\queryparser\xml\builders\TestNumericRangeFilterBuilder.class, source line 206
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 215
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 245
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 385
          [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String;
          [forbidden-method-calls]   in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 766
          [forbidden-method-calls] Scanned 4959 class file(s) for forbidden method invocations (in 2.45s.), 75 error(s).
          
          BUILD FAILED
          C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build.xml:179: The following error occurred while executing this line:
          C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\tools\custom-tasks.xml:70: Check for forbidden method calls failed, see log.
          

          for this simple list of methods:

          addConstructor(String.class, byte[].class);
          addConstructor(String.class, byte[].class, int.class);
          addConstructor(String.class, byte[].class, int.class, int.class);
          addConstructor(String.class, byte[].class, int.class, int.class, int.class);
          addMethod(String.class, "getBytes");
          addMethod(String.class, "toLowerCase");
          addMethod(String.class, "toUpperCase");
          

          Further improvements coming:

          I prefer to make the method declarations type safe, so the TASK needs all classes with illegal methods in classpath. For Lucene this is no problem, as it only uses JDK classes.
          In Solr, we should also add commons.io to this classpath, as lots of tests and core classes use the horrible IOUtils methods to converty binary files to strings or copy InputStreams to Strings. I will think about a more dynamic syntax to declare method invocations, than the above hardcoded java code.

          The task is simply called on a FileSet of .class files, currently like all other linters from top-level only.

          Show
          Uwe Schindler added a comment - Very rough patch for testing and it already found 75 errors: validate2: [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\java\org\apache\lucene\analysis\br\BrazilianStemmer.class, source line 246 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\java\org\apache\lucene\analysis\de\GermanStemmer.class, source line 50 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\sinks\TestTeeSinkTokenFilter.class, source line 167 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\sinks\TestTeeSinkTokenFilter.class, source line 183 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 261 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 308 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharArraySet.class, source line 354 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 56 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 73 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 87 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 87 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 101 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\common\classes\test\org\apache\lucene\analysis\util\TestCharTokenizers.class, source line 101 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\Compile.class, source line 92 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\Compile.class, source line 130 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\java\org\egothor\stemmer\DiffIt.class, source line 101 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toUpperCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 110 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 127 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 135 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 135 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 146 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\analysis\stempel\classes\test\org\egothor\stemmer\TestCompile.class, source line 146 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\feeds\EnwikiContentSource$Parser.class, source line 149 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\tasks\TaskSequence.class, source line 490 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\benchmark\classes\java\org\apache\lucene\benchmark\byTask\utils\Algorithm.class, source line 162 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 40 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 65 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 78 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\document\TestBinaryDocument.class, source line 97 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 46 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 76 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 99 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\index\TestPayloads.class, source line 100 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics$SimplePayloadFilter.class, source line 84 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 414 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 429 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 430 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 442 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 443 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 444 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 473 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 474 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 475 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestBasics.class, source line 476 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans$PayloadFilter.class, source line 508 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans$PayloadFilter.class, source line 510 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 279 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 314 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 350 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 386 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([B)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\core\classes\test\org\apache\lucene\search\spans\TestPayloadSpans.class, source line 458 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 45 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 54 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCharBlockArray.class, source line 63 [forbidden-method-calls] Forbidden method invocation: java/lang/String#<init>([BII)V [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\facet\classes\test\org\apache\lucene\facet\taxonomy\writercache\cl2o\TestCompactLabelToOrdinal.class, source line 49 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 661 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 662 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 938 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 967 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 1001 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\classic\QueryParserBase.class, source line 1021 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 154 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 158 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 163 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\nodes\QueryNodeImpl.class, source line 167 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\util\UnescapedCharSequence.class, source line 151 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\core\util\UnescapedCharSequence.class, source line 155 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 53 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 76 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\java\org\apache\lucene\queryparser\flexible\standard\parser\EscapeQuerySyntaxImpl.class, source line 181 [forbidden-method-calls] Forbidden method invocation: java/lang/String#getBytes()[B [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\queryparser\classes\test\org\apache\lucene\queryparser\xml\builders\TestNumericRangeFilterBuilder.class, source line 206 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 215 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 245 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 385 [forbidden-method-calls] Forbidden method invocation: java/lang/String#toLowerCase()Ljava/lang/String; [forbidden-method-calls] in C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build\suggest\classes\java\org\apache\lucene\search\suggest\jaspell\JaspellTernarySearchTrie.class, source line 766 [forbidden-method-calls] Scanned 4959 class file(s) for forbidden method invocations (in 2.45s.), 75 error(s). BUILD FAILED C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\build.xml:179: The following error occurred while executing this line: C:\Users\Uwe Schindler\Projects\lucene\trunk-lusolr0\lucene\tools\custom-tasks.xml:70: Check for forbidden method calls failed, see log. for this simple list of methods: addConstructor( String .class, byte [].class); addConstructor( String .class, byte [].class, int .class); addConstructor( String .class, byte [].class, int .class, int .class); addConstructor( String .class, byte [].class, int .class, int .class, int .class); addMethod( String .class, "getBytes" ); addMethod( String .class, "toLowerCase" ); addMethod( String .class, "toUpperCase" ); Further improvements coming: I prefer to make the method declarations type safe, so the TASK needs all classes with illegal methods in classpath. For Lucene this is no problem, as it only uses JDK classes. In Solr, we should also add commons.io to this classpath, as lots of tests and core classes use the horrible IOUtils methods to converty binary files to strings or copy InputStreams to Strings. I will think about a more dynamic syntax to declare method invocations, than the above hardcoded java code. The task is simply called on a FileSet of .class files, currently like all other linters from top-level only.
          Hide
          Uwe Schindler added a comment -

          Patch with full-featured ANT task and advanced list of methods:

          • Text-based method declarations are in separate text file(s) provided by <methodFileSet/>, inline as CDATA, or with methodFile-attribute
          • Support for <classpath/>, classpath attribute, or classpathRef attribute (used for parsing the method files - Solr uses this to point the parser to commons-io.jar)
          • inner fileset points to all */.class files to validate

          Currently the task is on top-level in Solr and Lucene and depends on compilation of tests (including core). It could maybe be per-module, but this may cause PermGen problems.

          Currently not run automatically, list of methods should be extended. But we already have too many violations!

          Show
          Uwe Schindler added a comment - Patch with full-featured ANT task and advanced list of methods: Text-based method declarations are in separate text file(s) provided by <methodFileSet/>, inline as CDATA, or with methodFile-attribute Support for <classpath/>, classpath attribute, or classpathRef attribute (used for parsing the method files - Solr uses this to point the parser to commons-io.jar) inner fileset points to all * / .class files to validate Currently the task is on top-level in Solr and Lucene and depends on compilation of tests (including core). It could maybe be per-module, but this may cause PermGen problems. Currently not run automatically, list of methods should be extended. But we already have too many violations!
          Hide
          Uwe Schindler added a comment -

          Executing the linter by: ant check-forbidden-methods (top-level, solr, or lucene)

          Show
          Uwe Schindler added a comment - Executing the linter by: ant check-forbidden-methods (top-level, solr, or lucene)
          Hide
          Dawid Weiss added a comment -

          +1 for top-level only. Can we make it a dependency of validate?

          Show
          Dawid Weiss added a comment - +1 for top-level only. Can we make it a dependency of validate?
          Hide
          Uwe Schindler added a comment - - edited

          New patch with improvements:

          • Use ASM-4.0 with generics support (asm-debug-all).
          • Add licence and notice files.
          • Separate the 2 tasks and make validate task depend on licenses and forbidden task.
          • Rename to "forbidden-api". The revised version now supports discouraging whole classes (FileReader, FileWriter), so not all ctors must be explicitely listed. The ant target only doing the API checks is now "ant check-forbidden-apis".
          • More compact output (format of class file and line numbers like in Java Stack traces).

          I think it's ready to commit, we may only disable some of the classes that are forbidden until fixed. We may also add option to not fail the build, but warn only.

          Show
          Uwe Schindler added a comment - - edited New patch with improvements: Use ASM-4.0 with generics support (asm-debug-all). Add licence and notice files. Separate the 2 tasks and make validate task depend on licenses and forbidden task. Rename to "forbidden-api". The revised version now supports discouraging whole classes (FileReader, FileWriter), so not all ctors must be explicitely listed. The ant target only doing the API checks is now "ant check-forbidden-apis". More compact output (format of class file and line numbers like in Java Stack traces). I think it's ready to commit, we may only disable some of the classes that are forbidden until fixed. We may also add option to not fail the build, but warn only.
          Hide
          Robert Muir added a comment -

          We may also add option to not fail the build, but warn only.

          Lets please not do this. Nobody ever does anything about warnings.

          Show
          Robert Muir added a comment - We may also add option to not fail the build, but warn only. Lets please not do this. Nobody ever does anything about warnings.
          Hide
          Chris Male added a comment -

          I agree with Robert, this seems like something we should force devs to care about.

          Show
          Chris Male added a comment - I agree with Robert, this seems like something we should force devs to care about.
          Hide
          Robert Muir added a comment -

          If you care about something at all, fix it across the entire codebase and then make hudson fail on it.

          Then it will stay fixed. Otherwise you are fighting a losing battle.

          Show
          Robert Muir added a comment - If you care about something at all, fix it across the entire codebase and then make hudson fail on it. Then it will stay fixed. Otherwise you are fighting a losing battle.
          Hide
          Uwe Schindler added a comment -

          fix charset bug in notice file as noted by Robert in chat die,die,die

          Show
          Uwe Schindler added a comment - fix charset bug in notice file as noted by Robert in chat die,die,die
          Hide
          Robert Muir added a comment -

          Lemme get some coffee made, I say lets create subtasks and fix all this crap and lock it into hudson

          Show
          Robert Muir added a comment - Lemme get some coffee made, I say lets create subtasks and fix all this crap and lock it into hudson
          Hide
          Robert Muir added a comment -
          Show
          Robert Muir added a comment - Here is a heavy committing branch: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene4199
          Hide
          Uwe Schindler added a comment -

          Thanks! Thats helkpful.

          I found in the PMD and FindBugs projects list of APIs:

          Actually findbugs has a plugin to do that but PMD has not yet resolved the issue at all. So my detector which is horribly fast is the best we get at the moment (http://sourceforge.net/tracker/?func=detail&atid=479921&aid=2978603&group_id=56262).

          Show
          Uwe Schindler added a comment - Thanks! Thats helkpful. I found in the PMD and FindBugs projects list of APIs: http://old.nabble.com/Default-charset-detector-td16231149.html [we can copypaste!] Actually findbugs has a plugin to do that but PMD has not yet resolved the issue at all. So my detector which is horribly fast is the best we get at the moment ( http://sourceforge.net/tracker/?func=detail&atid=479921&aid=2978603&group_id=56262 ).
          Hide
          Robert Muir added a comment -

          I think I am working to make the list shorter at the same time Uwe is working to make it longer!

          Show
          Robert Muir added a comment - I think I am working to make the list shorter at the same time Uwe is working to make it longer!
          Hide
          Uwe Schindler added a comment -

          LOL, I stopped adding new ones. I just heavy committed some fixes in the list, too!

          Show
          Uwe Schindler added a comment - LOL, I stopped adding new ones. I just heavy committed some fixes in the list, too!
          Hide
          Robert Muir added a comment -

          I wanted to run the checker under solr, but I got this error:

          check-forbidden-apis:
          
          BUILD FAILED
          /home/rmuir/workspace/lucene-trunk/solr/build.xml:194: No method found with following signature: org.apache.commons.io.IOUtils#toInputStream(java.lang.CharSequence)
          
          Total time: 26 seconds
          

          Do you know whats up?

          Show
          Robert Muir added a comment - I wanted to run the checker under solr, but I got this error: check-forbidden-apis: BUILD FAILED /home/rmuir/workspace/lucene-trunk/solr/build.xml:194: No method found with following signature: org.apache.commons.io.IOUtils#toInputStream(java.lang.CharSequence) Total time: 26 seconds Do you know whats up?
          Hide
          Robert Muir added a comment -

          I know the problem: its because i have apache-rat-0.8.jar in my .ant/lib

          This contains an embedded older commons-io that does not have this method.

          I wonder if the checker can ignore ant's classpath?

          Show
          Robert Muir added a comment - I know the problem: its because i have apache-rat-0.8.jar in my .ant/lib This contains an embedded older commons-io that does not have this method. I wonder if the checker can ignore ant's classpath?
          Hide
          Robert Muir added a comment -

          I removed rat from my .ant/lib, for now its working.

          I have an issue somewhere to make rat work via ivy-download, for some reason i could not make that work.
          We should revisit it sometime. Anyway ignore these problems, its not your problem

          Show
          Robert Muir added a comment - I removed rat from my .ant/lib, for now its working. I have an issue somewhere to make rat work via ivy-download, for some reason i could not make that work. We should revisit it sometime. Anyway ignore these problems, its not your problem
          Hide
          Dawid Weiss added a comment -

          This looks good enough to be useful as a stand-alone utility (or part of rat), actually. Minor comment –

          -  <path id="classpath"/>
          +  <path id="classpath">
          +    <fileset dir="lib">
          +      <include name="asm-debug-all-4.0.jar"/>
          +    </fileset>
          +  </path>
          

          we could probably change this to use ivycache; one place less to update versions, etc. I used two different ivy configs for junit4 - you can do a similar thing here if needed.

          Show
          Dawid Weiss added a comment - This looks good enough to be useful as a stand-alone utility (or part of rat), actually. Minor comment – - <path id= "classpath" /> + <path id= "classpath" > + <fileset dir= "lib" > + <include name= "asm-debug-all-4.0.jar" /> + </fileset> + </path> we could probably change this to use ivycache; one place less to update versions, etc. I used two different ivy configs for junit4 - you can do a similar thing here if needed.
          Hide
          Uwe Schindler added a comment -

          Here is the final patch for trunk merged from our heavy committing branch.

          Thanks to Robert for doing all the work in fixing Lucene and Solr.

          Solr's DIH is currently exclude from the checks because of SOLR-1916.

          We will commit this now, as it may get outdated fast. We need to backport after that.

          Show
          Uwe Schindler added a comment - Here is the final patch for trunk merged from our heavy committing branch. Thanks to Robert for doing all the work in fixing Lucene and Solr. Solr's DIH is currently exclude from the checks because of SOLR-1916 . We will commit this now, as it may get outdated fast. We need to backport after that.
          Hide
          Robert Muir added a comment -

          +1. Ill do a check under lucene/ to ensure everything is passing with UTF-16 default charset.

          We cant check this yet for solr/ because of http://jira.codehaus.org/browse/JETTY-1532

          Show
          Robert Muir added a comment - +1. Ill do a check under lucene/ to ensure everything is passing with UTF-16 default charset. We cant check this yet for solr/ because of http://jira.codehaus.org/browse/JETTY-1532
          Hide
          Uwe Schindler added a comment -

          Committed trunk revision: 1359202

          Now backporting!

          Show
          Uwe Schindler added a comment - Committed trunk revision: 1359202 Now backporting!
          Hide
          Robert Muir added a comment -

          UTF-16 tests passed on my windows box. So we are ok on trunk!

          On branch_4x i think the fixes are easy: just some deprecated stuff. No errors in solr.

          Show
          Robert Muir added a comment - UTF-16 tests passed on my windows box. So we are ok on trunk! On branch_4x i think the fixes are easy: just some deprecated stuff. No errors in solr.
          Hide
          Uwe Schindler added a comment -

          Committed 4.x revision: 1359229

          Thanks Robert for the hard work in assisting a one-armed guy

          Show
          Uwe Schindler added a comment - Committed 4.x revision: 1359229 Thanks Robert for the hard work in assisting a one-armed guy
          Hide
          Hoss Man added a comment -

          hoss20120711-manual-post-40alpha-change

          Show
          Hoss Man added a comment - hoss20120711-manual-post-40alpha-change
          Hide
          Uwe Schindler added a comment -

          I just wanted to add my recent blog post on this issue as further documentation: http://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html

          Show
          Uwe Schindler added a comment - I just wanted to add my recent blog post on this issue as further documentation: http://blog.thetaphi.de/2012/07/default-locales-default-charsets-and.html

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development