diff --git a/.travis/build-site.sh b/.travis/build-site.sh deleted file mode 100755 index 3d3fa5a43d..0000000000 --- a/.travis/build-site.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -set -e - -source .travis/common-functions.sh - -VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "Building PMD Site ${VERSION} on branch ${TRAVIS_BRANCH}" - -if ! travis_isPush; then - echo "Not building site, since this is not a push!" - exit 0 -fi - - -( - # Run the build, truncate output due to Travis log limits - - echo -e "\n\nExecuting ./mvnw install..." - travis_wait ./mvnw install -DskipTests=true -B -V -q - echo "Finished executing ./mvnw install" - - echo -e "\n\nExecuting ./mvnw site site:stage... - travis_wait 40 ./mvnw site site:stage -DskipTests=true -Psite -B -V -q - echo "Finished executing ./mvnw site site:stage..." -) - -echo -e "\n\nCreating pmd-doc archive...\n\n" -( - cd target - mv staging pmd-doc-${VERSION} - zip -qr pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/ -) - -# Uploading pmd doc distribution to sourceforge -if [[ "$TRAVIS_TAG" != "" || "$VERSION" == *-SNAPSHOT ]]; then - rsync -avh target/pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ -fi - -( - if [[ "$VERSION" == *-SNAPSHOT && "$TRAVIS_BRANCH" == "master" ]]; then - echo -e "\n\nUploading snapshot site...\n\n" - travis_wait rsync -ah --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/ - fi -) diff --git a/src/site/resources/images/logo/pmd_logo.jpg b/docs/images/logo/pmd_logo.jpg similarity index 100% rename from src/site/resources/images/logo/pmd_logo.jpg rename to docs/images/logo/pmd_logo.jpg diff --git a/src/site/resources/images/logo/pmd_logo.png b/docs/images/logo/pmd_logo.png similarity index 100% rename from src/site/resources/images/logo/pmd_logo.png rename to docs/images/logo/pmd_logo.png diff --git a/src/site/resources/images/logo/pmd_logo.svgz b/docs/images/logo/pmd_logo.svgz similarity index 100% rename from src/site/resources/images/logo/pmd_logo.svgz rename to docs/images/logo/pmd_logo.svgz diff --git a/src/site/resources/images/logo/pmd_logo_small.jpg b/docs/images/logo/pmd_logo_small.jpg similarity index 100% rename from src/site/resources/images/logo/pmd_logo_small.jpg rename to docs/images/logo/pmd_logo_small.jpg diff --git a/src/site/resources/images/logo/pmd_logo_small.png b/docs/images/logo/pmd_logo_small.png similarity index 100% rename from src/site/resources/images/logo/pmd_logo_small.png rename to docs/images/logo/pmd_logo_small.png diff --git a/src/site/resources/images/logo/pmd_logo_tiny.png b/docs/images/logo/pmd_logo_tiny.png similarity index 100% rename from src/site/resources/images/logo/pmd_logo_tiny.png rename to docs/images/logo/pmd_logo_tiny.png diff --git a/docs/pages/pmd/devdocs/writing_xpath_rules.md b/docs/pages/pmd/devdocs/writing_xpath_rules.md index 72d63fe0ba..efab126832 100644 --- a/docs/pages/pmd/devdocs/writing_xpath_rules.md +++ b/docs/pages/pmd/devdocs/writing_xpath_rules.md @@ -10,6 +10,9 @@ folder: pmd/devdocs # XPath Rule tutorial +{% include note.html content="For a translation to Gregorian, see [webhostinggeeks.com/science/xpath-sourceforge-ka](http://webhostinggeeks.com/science/xpath-sourceforge-ka)" %} + + Writing PMD rules with XPath can be a bit easier than writing rules with Java code. Here’s an introduction on how to do that. ## Introduction diff --git a/pmd-apex/src/site/markdown/index.md b/pmd-apex/src/site/markdown/index.md deleted file mode 100644 index 945725b02e..0000000000 --- a/pmd-apex/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD Apex - -Contains the PMD implementation to support the Apex programming language. - -Please note, that this module requires a Java 8 runtime environment. diff --git a/pmd-apex/src/site/site.pre.xml b/pmd-apex/src/site/site.pre.xml deleted file mode 100644 index c40376319d..0000000000 --- a/pmd-apex/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-core/src/site/markdown/index.md b/pmd-core/src/site/markdown/index.md deleted file mode 100644 index f5f1c9fb3a..0000000000 --- a/pmd-core/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD - -Contains the core packages and API needed to implement support for specific languages. diff --git a/pmd-cpp/src/site/markdown/index.md b/pmd-cpp/src/site/markdown/index.md deleted file mode 100644 index 3b79f03162..0000000000 --- a/pmd-cpp/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD C++ - -Only CPD is supported. There are no PMD rules for C++. diff --git a/pmd-cs/src/site/markdown/index.md b/pmd-cs/src/site/markdown/index.md deleted file mode 100644 index 4a4bca4837..0000000000 --- a/pmd-cs/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD C## - -Only CPD is supported. There are no PMD rules for C#. diff --git a/pmd-dist/src/site/markdown/index.md b/pmd-dist/src/site/markdown/index.md deleted file mode 100644 index 825485669e..0000000000 --- a/pmd-dist/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Distribution Packages - -This is the maven module, which generates the binary and source packages of PMD. diff --git a/pmd-fortran/src/site/markdown/index.md b/pmd-fortran/src/site/markdown/index.md deleted file mode 100644 index 808bc4fa7b..0000000000 --- a/pmd-fortran/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Fortran - -Only CPD is supported. There are no PMD rules for Fortran. diff --git a/pmd-go/src/site/markdown/index.md b/pmd-go/src/site/markdown/index.md deleted file mode 100644 index 15872a4ff7..0000000000 --- a/pmd-go/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Go - -Only CPD is supported. There are no PMD rules for [Go](https://golang.org/). diff --git a/pmd-groovy/src/site/markdown/index.md b/pmd-groovy/src/site/markdown/index.md deleted file mode 100644 index 1164be9a2f..0000000000 --- a/pmd-groovy/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Groovy - -Only CPD is supported. There are no PMD rules for Groovy at the moment. diff --git a/pmd-java/src/site/markdown/index.md b/pmd-java/src/site/markdown/index.md deleted file mode 100644 index 8599ca76f9..0000000000 --- a/pmd-java/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD Java - -Contains the PMD implementation to support the Java programming language. - -For the available rules, see rulesets index page. diff --git a/pmd-java/src/site/site.pre.xml b/pmd-java/src/site/site.pre.xml deleted file mode 100644 index 6bbb74db55..0000000000 --- a/pmd-java/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-java8/src/site/markdown/index.md b/pmd-java8/src/site/markdown/index.md deleted file mode 100644 index ecbb222c85..0000000000 --- a/pmd-java8/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD Java8 Integration Tests - -Some integrations test for the language module pmd-java require -compiled java classes, which use the class format of java8. -This module contains these test classes. diff --git a/pmd-javascript/src/site/markdown/index.md b/pmd-javascript/src/site/markdown/index.md deleted file mode 100644 index 24c7020097..0000000000 --- a/pmd-javascript/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD JavaScript - -Contains the PMD implementation to support the JavaScript programming language. - -For the available rules, see rulesets index page. diff --git a/pmd-javascript/src/site/site.pre.xml b/pmd-javascript/src/site/site.pre.xml deleted file mode 100644 index aa54fe79d9..0000000000 --- a/pmd-javascript/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-jsp/src/site/markdown/index.md b/pmd-jsp/src/site/markdown/index.md deleted file mode 100644 index d8112908ac..0000000000 --- a/pmd-jsp/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD JSP - -Contains the PMD implementation to support Java Server Pages. - -For the available rules, see rulesets index page. diff --git a/pmd-jsp/src/site/site.pre.xml b/pmd-jsp/src/site/site.pre.xml deleted file mode 100644 index f012ef958a..0000000000 --- a/pmd-jsp/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-matlab/src/site/markdown/index.md b/pmd-matlab/src/site/markdown/index.md deleted file mode 100644 index 4fa58a523d..0000000000 --- a/pmd-matlab/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Matlab - -Only CPD is supported. There are no PMD rules for Matlab. diff --git a/pmd-objectivec/src/site/markdown/index.md b/pmd-objectivec/src/site/markdown/index.md deleted file mode 100644 index 032f2e53ac..0000000000 --- a/pmd-objectivec/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Objective-C - -Only CPD is supported. There are no PMD rules for Objective-C. diff --git a/pmd-perl/src/site/markdown/index.md b/pmd-perl/src/site/markdown/index.md deleted file mode 100644 index 251674558c..0000000000 --- a/pmd-perl/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD Perl - -Contains the PMD implementation to support the Perl programming language. - -Only very basic CPD support is implemented currently. diff --git a/pmd-php/src/site/markdown/index.md b/pmd-php/src/site/markdown/index.md deleted file mode 100644 index 43f979c0bb..0000000000 --- a/pmd-php/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD PHP - -Only CPD is supported. There are no PMD rules for PHP. diff --git a/pmd-plsql/src/site/markdown/index.md b/pmd-plsql/src/site/markdown/index.md deleted file mode 100644 index ed4af64260..0000000000 --- a/pmd-plsql/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD PL/SQL - -Contains the PMD implementation to support PL/SQL. - -For the available rules, see rulesets index page. diff --git a/pmd-plsql/src/site/site.pre.xml b/pmd-plsql/src/site/site.pre.xml deleted file mode 100644 index e7ad19da8e..0000000000 --- a/pmd-plsql/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-python/src/site/markdown/index.md b/pmd-python/src/site/markdown/index.md deleted file mode 100644 index 68427c8367..0000000000 --- a/pmd-python/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Python - -Only CPD is supported. There are no PMD rules for Python. diff --git a/pmd-ruby/src/site/markdown/index.md b/pmd-ruby/src/site/markdown/index.md deleted file mode 100644 index 69a30fbed0..0000000000 --- a/pmd-ruby/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Ruby - -Only CPD is supported. There are no PMD rules for Ruby. diff --git a/pmd-scala/src/site/markdown/index.md b/pmd-scala/src/site/markdown/index.md deleted file mode 100644 index 0ea01c0741..0000000000 --- a/pmd-scala/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Scala - -Only CPD is supported. There are no PMD rules for Scala. diff --git a/pmd-swift/src/site/markdown/index.md b/pmd-swift/src/site/markdown/index.md deleted file mode 100644 index ac13d040c0..0000000000 --- a/pmd-swift/src/site/markdown/index.md +++ /dev/null @@ -1,3 +0,0 @@ -# PMD Swift - -Only CPD is supported. There are no PMD rules for Swift. diff --git a/pmd-test/src/site/markdown/index.md b/pmd-test/src/site/markdown/index.md deleted file mode 100644 index 9d15c2d9dd..0000000000 --- a/pmd-test/src/site/markdown/index.md +++ /dev/null @@ -1,6 +0,0 @@ -# PMD Test Framework - -This module provides a framework to run tests for rules. -It is usually used by the language modules in order to write -unit tests with real code samples. - diff --git a/pmd-ui/src/site/markdown/index.md b/pmd-ui/src/site/markdown/index.md deleted file mode 100644 index 36a29ab699..0000000000 --- a/pmd-ui/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD UI Applications - -Future place for the UI applications of PMD and CPD. -Currently the applications are part of the module pmd-core. - diff --git a/pmd-visualforce/src/site/markdown/index.md b/pmd-visualforce/src/site/markdown/index.md deleted file mode 100644 index 5f70549cd2..0000000000 --- a/pmd-visualforce/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD VF - -Contains the PMD implementation to support Salesforce VisualForce. - -For the available rules, see rulesets index page. diff --git a/pmd-visualforce/src/site/site.pre.xml b/pmd-visualforce/src/site/site.pre.xml deleted file mode 100644 index 6ae7aa9380..0000000000 --- a/pmd-visualforce/src/site/site.pre.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-vm/src/site/markdown/index.md b/pmd-vm/src/site/markdown/index.md deleted file mode 100644 index 3cd3d3e744..0000000000 --- a/pmd-vm/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD Velocity - -Contains the PMD implementation to support the Velocity Template Language. - -For the available rules, see rulesets index page. diff --git a/pmd-vm/src/site/site.pre.xml b/pmd-vm/src/site/site.pre.xml deleted file mode 100644 index d8c9a4b800..0000000000 --- a/pmd-vm/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pmd-xml/src/site/markdown/index.md b/pmd-xml/src/site/markdown/index.md deleted file mode 100644 index 591bd1d2da..0000000000 --- a/pmd-xml/src/site/markdown/index.md +++ /dev/null @@ -1,5 +0,0 @@ -# PMD XML and XSL - -Contains the PMD implementation to support XML and XSL. - -For the available rules, see rulesets index page. diff --git a/pmd-xml/src/site/site.pre.xml b/pmd-xml/src/site/site.pre.xml deleted file mode 100644 index cc7ede3088..0000000000 --- a/pmd-xml/src/site/site.pre.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 9c6b65098e..897c97de60 100644 --- a/pom.xml +++ b/pom.xml @@ -245,10 +245,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code ossrh https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - local - file:///tmp/pmd-site - PMD @@ -381,18 +377,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code maven-shade-plugin 2.4.3 - - org.apache.maven.plugins - maven-site-plugin - 3.4 - - - org.apache.maven.doxia - doxia-module-markdown - 1.6 - - - org.apache.maven.plugins maven-surefire-plugin @@ -426,18 +410,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code build-helper-maven-plugin 1.9.1 - - net.sourceforge.pmd - pmd-build-tools-plugin - ${pmd.build-tools.version} - - - - pmd-pre-site - - - - org.apache.maven.plugins maven-source-plugin @@ -503,19 +475,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code - - org.apache.maven.plugins - maven-site-plugin - false - - - attach-site-descriptor - - attach-descriptor - - - - org.apache.maven.plugins maven-antrun-plugin @@ -963,17 +922,6 @@ Additionally it includes CPD, the copy-paste-detector. CPD finds duplicated code - - site - - - 1.8 - - - doclint diff --git a/src/site/fml/usage/faq.fml b/src/site/fml/usage/faq.fml deleted file mode 100644 index d6795d05ae..0000000000 --- a/src/site/fml/usage/faq.fml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - Development - - - - In which order are nodes visited? - - -

The parser performs a depth-first traversal. - Consider the given source:

- - - -

The visiting order here will be: -

    -
  1. Class Foo
  2. -
  3. Field name
  4. -
  5. Class Bar
  6. -
  7. Field x
  8. -
  9. Field total
  10. -
-

-

Note that the total field of Foo will be visited after visiting the fields in Bar. - You must take this into account for certain rules.

-
-
- - - - Is there a simple way of getting fields from a given class? - - -

Yes, the symbol table can supply that information.

-

FIXME add code example

-
-
-
- - Rules - - - - How useful are the rules? - - -

Have this clear: having a projects with no pmd violations does not mean at all, I repeat, - It does not mean at all, not at the minimum expected, that the project has any quality. - For illustrating this I'll tell a little story taken from my work (a sadly real story). - Some classes had fields that were reported as unused, (unused code ruleset) as developers - saw this, they wanted to remove the violation, (not fix the code, fix the violation) so - the action took was to add useless log sentences with something like: - 'unused variable '+unusedVariable. Belive it or not, the code was worse than the original - and reported less pmd violations. -

-

In a more positive way: use the rules as you see them fix, don't try to remove violations - per-se try to review the code and see if the particular cases you are using are correct or not. -

-
-
-
- -
diff --git a/src/site/markdown/customizing/compiling.md.vm b/src/site/markdown/customizing/compiling.md.vm deleted file mode 100644 index 1429531938..0000000000 --- a/src/site/markdown/customizing/compiling.md.vm +++ /dev/null @@ -1,88 +0,0 @@ - - -# Compiling PMD - -## Requirements - -* JDK 1.7 or higher -* [Apache Maven](http://maven.apache.org) 3 or later. - - -## Compiling PMD - -You'll need to either check out the source code or download the latest source release. -Assuming you've got the latest source release, unzip it to a directory: - - [tom@hal building]$ ls -l - total 5716 - -rw-rw-r-- 1 tom tom 5837216 Jul 17 13:09 pmd-src-${project.version}.zip - [tom@hal building]$ unzip -q pmd-src-${project.version}.zip - [tom@hal building]$ - -Now cd down into the pmd directory: - - [tom@hal building]$ cd pmd-src-${project.version} - [tom@hal pmd-src-${project.version}]$ ls -l | grep pom.xml - -rw-rw-r-- 1 tom tom 36482 14. Nov 17:36 pom.xml - [tom@hal pmd-src-${project.version}]$ - -That's the project configuration for maven... let's compile! - - [tom@hal pmd-src-${project.version}]$ mvn clean package - [INFO] Scanning for projects... - [INFO] ------------------------------------------------------------------------ - [INFO] Reactor Build Order: - [INFO] - [INFO] PMD - [INFO] PMD Core - ... - ... after a few minutes ... - [INFO] ------------------------------------------------------------------------ - [INFO] Reactor Summary: - [INFO] - [INFO] PMD ................................................ SUCCESS [ 3.061 s] - [INFO] PMD Core ........................................... SUCCESS [ 25.675 s] - [INFO] PMD Test Framework ................................. SUCCESS [ 0.457 s] - [INFO] PMD C++ ............................................ SUCCESS [ 1.893 s] - [INFO] PMD C# ............................................. SUCCESS [ 0.619 s] - [INFO] PMD Fortran ........................................ SUCCESS [ 0.609 s] - [INFO] PMD Go ............................................. SUCCESS [ 0.103 s] - [INFO] PMD Java ........................................... SUCCESS [01:08 min] - [INFO] PMD JavaScript ..................................... SUCCESS [ 3.279 s] - [INFO] PMD JSP ............................................ SUCCESS [ 3.944 s] - [INFO] PMD Matlab ......................................... SUCCESS [ 1.342 s] - [INFO] PMD Objective-C .................................... SUCCESS [ 2.281 s] - [INFO] PMD PHP ............................................ SUCCESS [ 0.536 s] - [INFO] PMD PL/SQL ......................................... SUCCESS [ 10.973 s] - [INFO] PMD Python ......................................... SUCCESS [ 1.758 s] - [INFO] PMD Ruby ........................................... SUCCESS [ 0.438 s] - [INFO] PMD Velocity ....................................... SUCCESS [ 3.941 s] - [INFO] PMD XML and XSL .................................... SUCCESS [ 2.174 s] - [INFO] PMD Scala .......................................... SUCCESS [ 11.901 s] - [INFO] PMD Distribution Packages .......................... SUCCESS [ 11.366 s] - [INFO] PMD Java 8 Integration ............................. SUCCESS [ 0.560 s] - [INFO] ------------------------------------------------------------------------ - [INFO] BUILD SUCCESS - [INFO] ------------------------------------------------------------------------ - [INFO] Total time: 02:36 min - [INFO] Finished at: 2015-11-14T17:46:06+01:00 - [INFO] Final Memory: 63M/765M - [INFO] ------------------------------------------------------------------------ - [tom@hal pmd-src-${project.version}]$ - -Now the source and binary distribution zip files can be found in -the folder `pmd-dist/target`. - -Notes: - -* The rules that have already been written are specified in the src/main/resources/rulesets/ directories - of the specific languages, e.g. `pmd-java/src/main/resources/rulesets`. They're also in the jar file that's included with both the - source and binary distributions. - -A paucity of detail, I'm sure you'd agree. If you think this document can be -improved, please post [here][forum] and let me know how. Thanks! - -[forum]: http://sourceforge.net/p/pmd/discussion/188192 diff --git a/src/site/markdown/customizing/cpd-parser-howto.md b/src/site/markdown/customizing/cpd-parser-howto.md deleted file mode 100644 index 97c2364dd2..0000000000 --- a/src/site/markdown/customizing/cpd-parser-howto.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# How to add a new language to CPD - -If you wish CPD to parse a unsupported language, you can easily develop a new parser -for CPD. All you need to is implements the following interface: - -* net.sourceforge.pmd.cpd.Language -* net.sourceforge.pmd.cpd.Tokenizer - -Do not forget to the follow the proper naming convention, as the CPD parser factory -use this convention: - -* Language Name + "Language" -* Tokenizer Name + "Tokenizer" - -For instance, if you develop a python parser, you should have two classes named PythonLanguage -and PythonTokenizer. - -To test your parser, just package it in a jar and add your jar to the classpath. diff --git a/src/site/markdown/customizing/howitworks.md b/src/site/markdown/customizing/howitworks.md deleted file mode 100644 index 3a059a5422..0000000000 --- a/src/site/markdown/customizing/howitworks.md +++ /dev/null @@ -1,22 +0,0 @@ - - -# How it works - -PMD checks source code against rules and produces a report. Like this: - -* Something passes a file name and a RuleSet into PMD -* PMD hands an InputStream to the file off to a JavaCC-generated parser -* PMD gets a reference to an Abstract Syntax Tree back from the parser -* PMD hands the AST off to the symbol table layer which builds scopes, finds declarations, and find usages. -* If any rules need data flow analysis, PMD hands the AST over to the DFA layer for building control flow - graphs and data flow nodes. -* Each Rule in the RuleSet gets to traverse the AST and check for problems. The rules can also poke around the - symbol table and DFA nodes. -* The Report is now filled with RuleViolations, and those get printed out in XML or HTML or whatever - -Not much detail here... if you think this document can be -improved, please post [here][forum] and let me know how. Thanks! - -[forum]: http://sourceforge.net/p/pmd/discussion/188192 diff --git a/src/site/markdown/customizing/howtomakearuleset.md b/src/site/markdown/customizing/howtomakearuleset.md deleted file mode 100644 index 19b15d0f91..0000000000 --- a/src/site/markdown/customizing/howtomakearuleset.md +++ /dev/null @@ -1,134 +0,0 @@ - - -# How to make a new rule set - -Say you want to pick specific rules from various rule sets and customize them. You can do this by making your own rule set. - -## Create a new ruleset.xml file - -Use one of the current rulesets as an example. Copy and paste it into your new file, delete all the old rules -from it, and change the name and description. Like this: - - - - - This ruleset checks my code for bad stuff - - - -## Add some rule references to it - -After you add these references it'll look something like this: - - - - - - This ruleset checks my code for bad stuff - - - - - - - - - - - - - - 2 - - - - - - - - - - - - - - - -Notice that you can customize individual referenced rules. Everything but the -class of the rule can be overridden in your custom ruleset. - -## Excluding rules from a ruleset - -You can also make a custom ruleset that excludes rules, like this: - - - - Just the braces rules I like - - - - - - -## Excluding files from a ruleset - -You can also exclude certain files from being processed by a ruleset using exclude patterns, -with an optional overriding include pattern. A file will be excluded from processing when there -is a matching exclude pattern, but no matching include pattern. Path separators in the source -file path are normalized to be the '/' character, so the same ruleset can be used on multiple -platforms transparently. Additionally, this exclude/include technique works regardless of how -PMD is used (e.g. command line, IDE, Ant), making it easier to keep application of your PMD -rules consistent throughout your environment. Here is an example: - - - - My ruleset - .*/some/package/.* - .*/some/other/package/FunkyClassNamePrefix.* - .*/some/package/ButNotThisClass.* - ... - - -## Reference it in your Ant task - -You can specify the full path to your custom ruleset name alongside -of the built-in PMD rulesets - like this: - - - - - - - - -## To see it in your IDE, add it to rulesets/rulesets.properties - -At least, that's the way some of the IDE plugins do it. Some -have other ways of adding custom rulesets. - -## Send us feedback - -If you have suggestions on clarifying this document, please post -them to [the forum][forum]. Thanks! - -[forum]: http://sourceforge.net/p/pmd/discussion/188192 - -Finally, for many more details on building custom rulesets, pick up [PMD Applied][pmdapplied]! - -[pmdapplied]: http://pmdapplied.com/ diff --git a/src/site/markdown/customizing/howtowritearule.md b/src/site/markdown/customizing/howtowritearule.md deleted file mode 100644 index 9ec16c15cd..0000000000 --- a/src/site/markdown/customizing/howtowritearule.md +++ /dev/null @@ -1,416 +0,0 @@ - - -# How to write a PMD rule - -Writing PMD rules is cool because you don't have to wait for us to get around to implementing feature requests. - -## Get a development environment set up first - -[Here's some initial information on compiling PMD][compiling] - -[compiling]: compiling.html - -## Java or XPath? - -There are two way to write rules: - -* Write a rule using Java -* Write an XPath expression - - -We'll cover the Java way first and the XPath way second. Most of this documentation is applicable -to both methods, too, so read on. - -## Figure out what you want to look for - -Lets's figure out what problem we want to spot. We can use "While loops must use braces" as an example. -In the source code below, it's easy to get lost visually - it's kind of hard to tell what the curly braces belong to. - - class Example { - void bar() { - while (baz) - buz.doSomething(); - } - } - -So we know what an example in source code looks like, which is half the battle. - -## Write a test-data example and look at the AST - -PMD doesn't use the source code directly; it uses a `JavaCC` -generated parser to parse the source code and -produce an AST (Abstract Syntax Tree). The AST for the code above looks like this: - - CompilationUnit - TypeDeclaration - ClassDeclaration:(package private) - UnmodifiedClassDeclaration(Example) - ClassBody - ClassBodyDeclaration - MethodDeclaration:(package private) - ResultType - MethodDeclarator(bar) - FormalParameters - Block - BlockStatement - Statement - WhileStatement - Expression - PrimaryExpression - PrimaryPrefix - Name:baz - Statement - StatementExpression:null - PrimaryExpression - PrimaryPrefix - Name:buz.doSomething - PrimarySuffix - Arguments - -You can generate this yourself by: - -* Run the batch file bin/designer.bat -* Paste the code into the left text area and click the "Go" button -* Note that there's another panel and a textfield to test out XPath expressions; more on that later. -* Here's a screenshot: - ![designer screenshot](../images/designer_screenshot.png) - -So you can see in the example above that the AST for a `WhileStatement` -looks kind of like this (excluding that expression gibberish for clarity): - - WhileStatement - Expression - Statement - StatementExpression - -If you were to add curly braces around the call to `buz.doSomething()` and click "Go" again, you'd see that the -AST would change a bit. It'd look like this: - - WhileStatement - Expression - Statement - Block - BlockStatement - Statement - StatementExpression - -Ah ha! We see that the curly braces add a couple more AST nodes - a `Block` -and a `BlockStatement`. So all we have -to do is write a rule to detect a `WhileStatement` that -has a `Statement` that's not followed by a `Block`, and we've got a rule violation. - - -By the way, all this structural information - i.e., the fact that a Statement may be -followed a Block - is concisely defined in the [EBNF grammar][grammar]. -So, for example, the Statement definition looks like this: - -[grammar]: https://github.com/pmd/pmd/blob/master/pmd-java/etc/grammar/Java.jjt - - void Statement() : - {} - { - LOOKAHEAD( { isNextTokenAnAssert() } ) AssertStatement() - | LOOKAHEAD(2) LabeledStatement() - | Block() - | EmptyStatement() - | StatementExpression() ";" - | SwitchStatement() - | IfStatement() - | WhileStatement() - | DoStatement() - | ForStatement() - | BreakStatement() - | ContinueStatement() - | ReturnStatement() - | ThrowStatement() - | SynchronizedStatement() - | TryStatement() - } - -]]> - -showing that a Statement may be followed by all sorts of stuff. - - -## Write a rule class - -Create a new Java class that extends `net.sourceforge.pmd.lang.java.rule.AbstractJavaRule`: - - import net.sourceforge.pmd.lang.java.rule.*; - public class WhileLoopsMustUseBracesRule extends AbstractJavaRule { - } - -That was easy. PMD works by creating the AST and then traverses it recursively so a rule can get a callback -for any type it's interested in. So let's make sure our rule gets called whenever -the AST traversal finds a `WhileStatement`: - - import net.sourceforge.pmd.lang.java.rule.*; - import net.sourceforge.pmd.lang.java.ast.*; - public class WhileLoopsMustUseBracesRule extends AbstractJavaRule { - public Object visit(ASTWhileStatement node, Object data) { - System.out.println("hello world"); - return data; - } - } - -We stuck a `println()` in there for now so we can see when our rule gets hit. - -## Put the WhileLoopsMustUseBracesRule rule in a ruleset file - -Now our rule is written - at least, the shell of it is - and now we need to tell PMD about it. We need -to add it to a ruleset XML file. Look at `pmd-java/src/main/resources/rulesets/java/basic.xml`; -it's got lots of rule definitions in it. -Copy and paste one of these rules into a new ruleset - call it `mycustomrules.xml` or something. -Then fill in the elements and attributes: - -* name - WhileLoopsMustUseBracesRule -* message - Use braces for while loops -* class - Wherever you put the rule. Note this doesn't have to be in `net.sourceforge.pmd`; - it can be in `com.yourcompany.util.pmd` or whereever you want -* description - Use braces for while loops -* example - A little code snippet in CDATA tags that shows a rule violation - -The whole ruleset file should look something like this: - - - - - - Avoid using 'while' statements without using curly braces - - 3 - - - - - - - -## Run PMD using your new ruleset - -OK, let's run the new rule so we can see something work. Like this: - - pmd.bat c:\path\to\my\src xml c:\path\to\mycustomrules.xml - -This time your "hello world" will show up right after the -AST gets printed out. If it doesn't, post a message to -[the forum][forum] so we can improve this document :-) - -[forum]: http://sourceforge.net/p/pmd/discussion/188192 - -## Write code to add rule violations where appropriate - -Now that we've identified our problem, recognized the AST pattern that -illustrates the problem, written a new rule, and plugged -it into a ruleset, we need to actually make our rule find the problem, create a `RuleViolation`, -and put it in the `Report`, which is attached to the `RuleContext`. Like this: - - import net.sourceforge.pmd.lang.ast.*; - import net.sourceforge.pmd.lang.java.ast.*; - import net.sourceforge.pmd.lang.java.rule.*; - - public class WhileLoopsMustUseBracesRule extends AbstractJavaRule { - public Object visit(ASTWhileStatement node, Object data) { - Node firstStmt = node.jjtGetChild(1); - if (!hasBlockAsFirstChild(firstStmt)) { - addViolation(data, node); - } - return super.visit(node,data); - } - private boolean hasBlockAsFirstChild(Node node) { - return (node.jjtGetNumChildren() != 0 && (node.jjtGetChild(0) instanceof ASTBlock)); - } - } - -TODO - if you don't understand the code for the rule, post a message -to [the forum][forum] so we can improve this document :-) - -## Writing a rule as an XPath expression - -Daniel Sheppard integrated an XPath engine into PMD, so now you can write rules as -XPath expressions. For example, the XPath expression for our WhileLoopsMustUseBracesRule looks like this: - - //WhileStatement[not(Statement/Block)] - -Concise, eh? Here's an [article](http://www.onjava.com/pub/a/onjava/2003/04/09/pmd_rules.html) with a lot more detail. - -Note that for XPath rules you'll need to set the `class` attribute in the rule definition to -`net.sourceforge.pmd.lang.rule.XPathRule.` Like this: - - - - etc., etc. - -Note that access modifiers are held as attributes, so, for example, - - //FieldDeclaration[@Private='true'] - -finds all private fields. You can see the code that determines all the attributes -[here](pmd-core/xref/net/sourceforge/pmd/lang/ast/xpath/AttributeAxisIterator.html) - -Thanks to Miguel Griffa for writing a longer [XPath tutorial](xpathruletutorial.html). - -## I want to implement a rule that analyze more than the class! - -An obvious limitation of the previous mechanism is the "class-centric" focus of the rule. How can you implement a -rule that checks stuff across the all source code? Let's take a dummy example. Let's say you want to implement a -rule that count how many Expression Node you have in your source code (told you, it was a dummy example :) ). - -You realize quite simply. You just have to add static field to the RulesContext, as an attribute, and uses -`Rule.start()` and `Rule.end()` hooks to initialize and finalize your rule's implementation: - - package net.sourceforge.pmd.rules; - - import java.util.concurrent.atomic.AtomicLong; - - import net.sourceforge.pmd.RuleContext; - import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; - import net.sourceforge.pmd.lang.java.ast.ASTExpression; - - public class CountRule extends AbstractJavaRule { - - private static final String COUNT = "count"; - - @Override - public void start(RuleContext ctx) { - ctx.setAttribute(COUNT, new AtomicLong()); - super.start(ctx); - } - - @Override - public Object visit(ASTExpression node, Object data) { - // How many Expression nodes are there in all files parsed! I must know! - RuleContext ctx = (RuleContext)data; - AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT); - total.incrementAndGet(); - return super.visit(node, data); - } - - @Override - public void end(RuleContext ctx) { - AtomicLong total = (AtomicLong)ctx.getAttribute(COUNT); - addViolation(ctx, null, new Object[] { total }); - ctx.removeAttribute(COUNT); - super.end(ctx); - } - } - -As you can see in this example, the method `start()` will be called once per file, right before it's analysis starts, -so you can initialize properly your rule here. Once the rule have finished analyzing the file's source code, -the method `end()` will be invoked you can assert there if your rule has been violated or not. - - -Note that the example logs a violation **without** a proper classname. This is not really a good idea. -Indeed, a lot of aggregating tools that PMD (Such as [XRadar][xradar], or [Sonar][sonar]) probably uses this kind -of meta data on their aggregation processes. So, when implements such a rule, always try to find a way to add -classname to the violation report. - - -[xradar]: http://xradar.sourceforge.net -[sonar]: http://www.sonarsource.com/ - - -## I need some kind of Type Resolution for my rule! - -PMD supports determining the type of nodes on the AST. For this to work you need: - -1. Include the attribute `typeResolution="true"` when defining the `rule` node on the ruleset XML. -2. The auxiliary classpath for PMD is setup correctly, so that PMD can actually find the (compiled) -classes. - -### Inside an XPath query - -PMD XPath syntax includes now a new function called `typeof` which determines if a node -(ClassOrInterfaceType only right now) is of the provided type. -It also scans the type's hierarchy, so if you extend a class it will also find this out. - -Here a an example of use, inside an XPath Query: - - //ClassOrInterfaceDeclaration[ - //ClassOrInterfaceType[typeof(@Image, 'junit.framework.TestCase','TestCase')] - ] - -This query will match on such source code: - - import junit.framework.TestCase; - - public class Foo extends TestCase { } - -### With Java code - -Below an other sample of use of type resolution inside a java code: - - /** - * A simple to detect the use of the class 'com.forbidden.class'. - */ - @SuppressWarnings("unchecked") - public Object visit(ASTClassOrInterfaceType type, Object ruleCtx) { - Class clazz = type.getType(); - if ("com.forbidden.class".equals(clazz.getName())) { - addViolation(ruleCtx,type); - } - return super.visit(type, ruleCtx); - } - -Notice `getType()` will return a `Class` object of the proper type, therefore -the need to have access to compiled classes in the auxiliar classpath. - -## Thread safety, concurrency issues and reuse of rule instances - -When executing the rule, PMD will instantiate a new instance of your rule. -If PMD is executed in multiple threads, then each thread is using its own -instance of the rule. This means, that the rule implementation -**does not need to care about threading issues**, -as PMD makes sure, that a single instance is not used -concurrently by multiple threads. - -However, for performance reasons, the rule instances are used for multiple files. This means, -that the constructor of the rule is only executed once (per thread) and the rule instance is reused. -If you rely on a proper initialization of instance properties, you can do the initialization -e.g. in the visit-method of the `ASTCompilationUnit` AST node - which is visited as first node -and only once per file. However, this solution would only work for rules written for the Java language. -A language independent way is to override the method `apply` of the rule (and call super). The -apply method is called exactly once per file. - -If you want to share data across multiple files, see the above section -"I want to implement a rule that analyze more than the class". - - -## Bundle it up - -To use your rules as part of a nightly build or whatever, it's helpful to bundle up both -the rule and the ruleset.xml file in a jar file. Then you can put that jar file on the CLASSPATH of -your build. Setting up a script or an Ant task to do this can save you some tedious typing. - -## Repeat as necessary - -I've found that my rules usually don't work the first time, and so I have to go back and tweak them a -couple times. That's OK, if we were perfect programmers PMD would be useless anyhow :-). - -As an acceptance test of sorts, I usually run a rule on the JDK 1.4 source code and make sure that a random -sampling of the problems found are in fact legitimate rule violations. -This also ensures that the rule doesn't get confused by nested -inner classes or any of the other oddities that appear at various points in the JDK source. - -You're rolling now. If you think a rule would benefit the Java development community as a whole, -post a message to [the forum][forum] so we can get the rule moved into one of the core rulesets. - -Or, if you can improve one of the existing rules, that'd be great too! Thanks! - -Finally, for many more details on writing rules, pick up [PMD Applied][pmdapplied]! - -[pmdapplied]: http://pmdapplied.com/ diff --git a/src/site/markdown/customizing/new-language.md b/src/site/markdown/customizing/new-language.md deleted file mode 100644 index 04100aaca3..0000000000 --- a/src/site/markdown/customizing/new-language.md +++ /dev/null @@ -1,63 +0,0 @@ -# Howto add a new language to PMD - -1. Start with a new sub-module. See pmd-java or pmd-vm for examples. -2. Implement an AST parser for your language - - ideally an AST parser should be implemented as a JJT file (see VmParser.jjt or Java.jjt for example) - - there is nothing preventing any other parser implementation, as long as you have some way to convert an input stream into an AST tree. Doing it as a JJT simplifies maintenance down the road. - - See this link for reference: https://javacc.java.net/doc/JJTree.html -3. Create AST node classes - - for each AST node that your parser can generate, there should be a class - - the name of the AST class should be "AST" + "whatever is the name of the node in JJT file". - - for example, if JJT contains a node called "IfStatement", there should be a class called "ASTIfStatement" - - each AST class should have two constructors: one that takes an int id; and one that takes an instance of the parser, and an int id - - it's a good idea to create a parent AST class for all AST classes of the language. This simplies rule creation later. See SimpleNode for Velocity and AbstractJavaNode for Java for example. - - Note: These AST node classes are generated usually once by javacc/jjtree and can then be modified as needed. -4. Compile your parser (if using JJT) - - an ant script is being used to compile jjt files into classes. This is in alljavacc.xml file. - - in the file, create a new target for your language. Use vmjjtree or javajjtree as an example. - - inside the alljavacctarget, add your new target to the "depends" list just before cleanup -5. Create a TokenManager - - create a new class that implements the TokenManager interface (see VmTokenManager or JavaTokenManager for example) -6. Create a PMD parser "adapter" - - create a new class that extends AbstractParser - - there are two important methods to implement - - createTokenManager method should return a new instance of a token manager for your language (see step #5) - - parse method should return the root node of the AST tree obtained by parsing the Reader source - - see VmParser class as an example -7. Create a rule violation factory - - extend AbstractRuleViolationFactory (see VmRuleViolationFactory for example) - - the purpose of this class is to createa rule violation instance specific to your language -8. Create a version handler - - extend AbstractLanguageVersionHandler (see VmHandler for example) - - this class is sort of a gateway between PMD and all parsing logic specific to your language. It has 3 purposes: - - getRuleViolationFactory method returns an instance of your rule violation factory (see step #7) - - getParser returns an instance of your parser adapter (see step #6) - - getDumpFacade returns a VisitorStarter that allows to dump a text representation of the AST into a writer (likely for debugging purposes) -9. Create a parser visitor adapter - - if you use JJT to generate your parser, it should also generate an interface for a parser visitor (see VmParserVisitor for example) - - create a class that implements this auto-generated interface (see VmParserVisitorAdapter for example) - - the purpose of this class is to serve as a pass-through visitor implementation, which, for all AST types in your language, just executes visit on the base AST type -10. Create a rule chain visitor - - extend AbstractRuleChainVisitor (see VmRuleChainVisitor for example) - - this class should implement two important methods: - - indexNodes generates a map of "node type" to "list of nodes of that type". This is used to visit all applicable nodes when a rule is applied. - - visit method should evaluate what kind of rule is being applied, and execute appropriate logic. Usually it will just check if the rule is a "parser visitor" kind of rule specific to your language, then execute the visitor. If it's an XPath rule, then we just need to execute evaluate on that. -11. Make PMD recognize your language - - Create your own subclass of net.sourceforge.pmd.lang.BaseLanguageModule. - See VmLanguageModule or JavaLanguageModule as an example. - - You'll need to refer the rule chain visitor created in step #10. - - Add for each version of your language a call to `addVersion` in your language module's constructor. - - Create the service registration via the text file `src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language`. - Add your fully qualified class name as a single line into it. -12. Create an abstract rule class for the language - - extend AbstractRule and implement the parser visitor interface for your language (see AbstractVmRule for example) - - all other rules for your language should extend this class. The purpose of this class is to implement visit methods for all AST types to simply delegate to default behavior. This is useful because most rules care only about specific AST nodes, but PMD needs to know what to do with each node - so this just lets you use default behavior for nodes you don't care about. -13. Create rules - - rules are ceated by extending the abstract rule class created in step #12 (see EmptyForeachStmtRule for example) - - creating rules is already pretty well documented in PMD - and it's no different for a new language, except you may have different AST nodes. -14. Test the rules - - see BasicRulesTest for example - - you have to create a rule set for your language (see vm/basic.xml for example) - - for each rule in this set you want to test, call addRule method in setUp of the unit test - - this triggers the unit test to read the corresponding XML file with rule test data (see EmptyForeachStmtRule.xml for example) - - this test XML file contains sample pieces of code which should trigger a specified number of violations of this rule. The unit test will execute the rule on this piece of code, and verify that the number of violations matches diff --git a/src/site/markdown/customizing/pmd-developer.md b/src/site/markdown/customizing/pmd-developer.md deleted file mode 100644 index 51f07c4e0f..0000000000 --- a/src/site/markdown/customizing/pmd-developer.md +++ /dev/null @@ -1,206 +0,0 @@ - - -# Informations for PMD developer - -Some piece of information handy to PMD developers. Clearly not everything, but some useful bits :) - -## PMD properties - -The new PMD properties subsystem is intended to bring some rigor and expanded functionality to the wild world of -rule properies. It defines a value type template that can be used by IDE plugins to enumerate the properties -specified by individual rules and provides validation and serialization services for multi-value properties. -It uses custom serialization routines to generate human-readable values that can be edited in the XML files. - -The subsystem implements the following property constructors with the leading name and description arguments not shown: - -1. BooleanProperty(..., boolean defaultValue, float uiOrder) -2. BooleanProperty(..., boolean[] defaultValues, uiOrder, maxValues) BooleanProperty(..., Boolean[] defaultValues, float uiOrder, int maxValues) -3. IntegerProperty(..., int defaultValue, float uiOrder) -4. IntegerProperty(..., int[]defaultValues, float uiOrder, int maxValues) IntegerProperty(..., Integer[] defaultValues, float uiOrder, int maxValues) -5. FloatProperty -6. FloatProperty(..., float defaultValue, float uiOrder) -7. FloatProperty(..., float[]defaultValues, float uiOrder, int maxValues) FloatProperty(..., Float[] defaultValues, float uiOrder, int maxValues) -8. DoubleProperty -9. DoubleProperty(..., int defaultValue, float uiOrder) -10. DoubleProperty (..., double[]defaultValues, float uiOrder, int maxValues) DoubleProperty (..., Double[] defaultValues, float uiOrder, int maxValues) -11. StringProperty -12. StringProperty(..., String defaultValue, float uiOrder) -13. StringProperty(..., String[] defaultValues, float uiOrder, char delimiter) - -The delimiter character is used in the serialized string and cannot be part of the property value strings. - -1. TypeProperty(..., Class defaultValue, float uiOrder) -2. TypeProperty(..., Class[]defaultValues, float uiOrder) - -_(PMD doesn’t currently support full type resolution at the moment)_ - -1. CharacterProperty(..., char defaultValue, float uiOrder) -2. CharacterProperty(..., char[] defaultValues, float uiOrder, char delimiter) -3. CharacterProperty(..., Character[] defaultValues, float uiOrder, char delimiter) -4. CharacterProperty(..., String defaultValues, float uiOrder, char delimiter) - -The delimiter character is used in the serialized string and cannot be part of the property value characters. - -1. EnumeratedProperty(..., Object[][] values, float uiOrder) -2. EnumeratedProperty(..., Object[][] values, float uiOrder, int maxValues) - -The 2D value array holds the label-value tuples in the order that they should be presented in the UI widget. -See usage below. - - -## For Rule developers - -All rule properties need to be characterized via individual PropertyDescriptors so that they can be viewed and -adjusted the IDE plugin users. Since the descriptors never change at runtime we only need one of each so we create -them as static singletons within the rule class definition. The following rule usage example makes use of a pair of -integer properties: - - public MyVarNameLengthRule extends AbstractRule() { - - private static final PropertyDescriptor minVarNameLength = - new IntegerProperty( - "minVarNameLength", - "Minimum length for variable names", - 3, - 1.0f - ); - - private static final PropertyDescriptor maxVarNameLength = - new IntegerProperty( - "maxVarNameLength", - "Maximum length for variable names", - 30, - 1.1f - ); - - private static final Map propertyDescriptorsByName = asFixedMap( - new PropertyDescriptor[] { minVarNameLength, maxVarNameLength } - ); - - public MyVarNameLengthRule() { }; - - protected Map propertiesByName() { - return propertyDescriptorsByName; - }; - - // rule body methods... - } - - -All property descriptors must be returned via the propertiesByName() method for each rule class. - -Properties can also be multi-valued, that is, we can capture and define a set of them at once: - - private static final PropertyDescriptor booleanPrefixes = - new StringProperty( - "booleanPrefixes", - "Legal prefixes to use for boolean field names", - new String[] { "is", "has", "can" }, - 1.0f, - '|' // reserved as delimiter - ); - - -There are at least two constructors for each property type, one that limits the property to a single -value and another that accepts more than one. - -In addition to the regular Java types such as Boolean, Integer, Float, Character, String, and Class/Type -values you can also allow your rule users to pick between complex mixed datatypes such as maps or graphs -that you define at compilation time: - - private static final Object[][] mixedItems = new Object[][] { - {"map", new HashMap()}, - {"emptyArray", new Object[0]}, - {"list", new ArrayList()}, - {"string", "Hello World!"}, - }; - - private static final PropertyDescriptor sampleObjects = - new EnumeratedProperty( - "testEnumerations", - "Test enumerations with complex types", - mixedItems, - 1.0f - ); - -Note that Java values held by the EnumeratedProperty are not written out as property values themselves, -we just write out the labels they are associated with. Specifying a label in the XML file for an object that -doesn’t exist will result in an IllegalArgumentException. - -## XML values - -Defining the property rules within the ruleset XML files is straightforward for single values: - - - - - -When specifying multiple values you will need to separate them using the delimiter held by the property descriptor, -most commonly a single pipe character, ‘|’: - - - - - -You can define your own datatypes by implementing a subclass of AbstractPMDProperty and implementing the -serialization, and validation routines listed in the PMDProperty interface. Just ensure that you create a -corresponding JUnit test in the test.net.sourceforge.pmd.properties package to go along with it. - -One of the implementation goals in this system is to try and come up with property constructors sufficiently useful -that we don’t need to assemble them within static blocks. A single statement should be enough to build a rule -property descriptor. - -## For IDE plugin developers - -In order to assemble an effective UI to manage the rule properties the following setup sequence is suggested: - -* Determine whether the value is open-ended or enumerated. For example, can the user type in their own values or - should they pick them from a list? Invoke the choices() method that may return a 2D array of label-value pairs - you can use to populate your list widget. If the method returns null then jump to step #2. - - You may need to maintain a mapping of the label-value pairs to translate between them depending on the - capabilities of your list widget. The first pair in the array represents the default property value. - -* For open-ended values, determine the cardinality of the property via the maxValueCount() method. If it - returns a value of one then use the type() method to determine the type-specific entry field could use next. - I.e. a checkbox for booleans, text field for strings, spin buttons for ints, etc. - -* If the property supports more than one value then you may opt to use a single text field and parse the entries - after the user leaves or hits the return key or you can create a read-only widget and add/remove values via - a popup dialog. - -* All multi-value properties make use of a character to delimit the values in their serialized form so you - will need to ensure that you prevent the user from entering values containing it. Retrieve the delimiter - via the multiValueDelimiter() method. - -You can use the errorFor(value) method to validate the values entered by the user or check the values held by the -rule configuration file. It returns null or an error message as appropriate. It would be best to flag and disable -rules that have invalid property values. - -Use the defaultValue() method to reset the rule properties to their default value. - -The two serialization methods, valueFrom() and asDelimitedString(), are to be used to retrive and store -property values respectively. - -Widgets should be ordered vertically according to the values returned by the uiOrder() method with -lower-valued properties appearing above the ones with higher values. The order of the property descriptors -returned from the rule cannot be guaranteed to be the same as the presentation order. If the two or more widgets -share the same integer value then you can use the fractional portions to place their widgets in a horizontal -sequence (if possible). - -For types that can have null values, such as strings, then use the isRequired() method to flag any -possible missing values. - -If a property field is multi-valued then the maximum number of values it can hold is set to largest possible int -value unless set explicitly in a rule property constructor. - -## ToDo items - -1. Expand this note with further examples -2. Internationalize error strings in the code -3. Provide for additional datatypes such as Date -4. Figure out the best way to add the rowCount value to the StringProperty constructor diff --git a/src/site/markdown/customizing/pmd-release-process.md b/src/site/markdown/customizing/pmd-release-process.md deleted file mode 100644 index c2ee60e77f..0000000000 --- a/src/site/markdown/customizing/pmd-release-process.md +++ /dev/null @@ -1,192 +0,0 @@ - - -# PMD Release Process - -This page describes the current status of the release process. - -Since versions 5.4.5 / 5.5.4 there is an automated release process using [travis-ci](https://travis-ci.org) -in place. However, there are still a few steps, that need manual examination. - -Note: You can find a small shell script in the root of the repo: `do-release.sh`. This script guides you -through the release process. - - -## Preparations - -Make sure code is up to date and everything is committed and pushed with git: - - $ mvn clean - $ git pull - $ git status - - - -### The Release Notes - -At a very minimum, the current date must be noted in the release notes. Also, the version -must be adjusted. E.g. by removing "-SNAPSHOT". - -You can find the release notes here: `src/site/markdown/overview/changelog.md`. - -The release notes usual mention any new rules that have been added since the last release. -Please double check the file `pmd-core/src/main/resources/rulesets/releases/.xml`, so -that all new rules are listed. - -Check in all (version) changes to branch master or any other branch, from which the release takes place: - - $ git commit -a -m "Prepare pmd release " - $ git push - - -### The Homepage - -The github repo `pmd.github.io` hosts the homepage for [https://pmd.github.io](https://pmd.github.io). -The `index.html` page needes to be updated to display the new release. The new release is mentioned - -* on the start page -* in the announcements -* and in the previous releases section - - -Check in all (version) changes to branch master: - - $ git commit -a -m "Prepare pmd release " - $ git push - - - -## Creating the release - -The release is created using the **maven-release-plugin**. This plugin changes the version by basically -removing the "-SNAPSHOT" suffix, builds the changed project locally, commits the version change, creates -a new tag from this commit, changes the version of the project to the next snapshot, commits this change -and pushes everything. - -`RELEASE_VERSION` is the version of the release. It is reused for the tag. `DEVELOPMENT_VERSION` is the -next snapshot version after the release. - - mvn -B release:clean release:prepare \ - -Dtag=pmd_releases/${RELEASE_VERSION} \ - -DreleaseVersion=${RELEASE_VERSION} \ - -DdevelopmentVersion=${DEVELOPMENT_VERSION} - - -Once the maven plugin has pushed the tag, travis-ci will start and build a new version from this tag. Since -it is a tag build and a released version build, travis-ci will do a couple of additional stuff: - -* Deploy and release the build to maven central, so that it can be downloaded from - . This is done automatically, if - all unit tests pass on travis-ci. The plugin [nexus-staging-maven-plugin](https://github.com/sonatype/nexus-maven-plugins/tree/master/staging/maven-plugin) is used for that. -* Upload the new binaries to github releases under . It also uploads - the release notes. -* Upload the new binaries additionally to sourceforge, so that they can be downloaded from - , including the release notes. The new binaries are - selected as the new default downloads for PMD. -* Add the documentation of the new release to a subfolder on , also make - this folder available as `latest`. - - -## After the release - -The release on travis currently takes about 30 minutes. Once this is done, you can spread the news: - -### Submit a news on SF - -Submit news to SF on the [PMD Project News](https://sourceforge.net/p/pmd/news/) page. You can use -the following template: - - PMD released - - * Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F - * Documentation: https://pmd.github.io/pmd-/ - - And Copy-Paste the release notes - -### Write an email to the mailing list - - To: PMD Developers List - Subject: [ANNOUNCE] PMD released - - - * Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F - * Documentation: https://pmd.github.io/pmd-/ - - And Copy-Paste the release notes - - -## Prepare the next release - -### Prepare the new release notes - -* Move version/release info from **src/site/markdown/overview/changelog.md** to **src/site/markdown/overview/changelog-old.md**. -* Update version/release info in **src/site/markdown/overview/changelog.md**. Use the following template: - - - # PMD Release Notes - - ## ????? - ${DEVELOPMENT_VERSION} - - The PMD team is pleased to announce PMD ${DEVELOPMENT_VERSION%-SNAPSHOT}. - - This is a bug fixing release. - - ### Table Of Contents - - * [New and noteworthy](#New_and_noteworthy) - * [Fixed Issues](#Fixed_Issues) - * [API Changes](#API_Changes) - * [External Contributions](#External_Contributions) - - ### New and noteworthy - - ### Fixed Issues - - ### API Changes - - ### External Contributions - -Commit and push - - $ git commit -m "Prepare next development version" - $ git push origin master - - -### Close / Create new milestones - -Manage the milestones under . -Maybe there are some milestones on sourceforge, too: . - - - -## Branches - -### Merging - -If the release was done on a maintenance branch, such as `pmd/5.4.x`, then this branch should be -merge into the next "higher" branches, such as `pmd/5.5.x` and `master`. - -This ensures, that all fixes done on the maintenance branch, finally end up in the other branches. -In theory, the fixes should already be there, but you never now. - - -### Multiple releases - -If releases from multiple branches are being done, the order matters. You should start from the "oldes" branch, -e.g. `pmd/5.4.x`, release from there. Then merge (see above) into the next branch, e.g. `pmd/5.5.x` and release -from there. Then merge into the `master` branch and release from there. This way, the last release done, becomes -automatically the latest release on and on sourceforge. - - -### (Optional) Create a new release branch - -At some point, it might be time for a new maintenance branch. Such a branch is usually created from -the `master` branch. Here are the steps: - -* Create a new branch: `git branch pmd/5.6.x master` -* Update the version in both the new branch and master, e.g. `mvn versions:set -Dversion=5.6.0-SNAPSHOT` - and `mvn versions:set -Dversion=5.7.0-SNAPSHOT`. -* Update the release notes on both the new branch and master - diff --git a/src/site/markdown/customizing/rule-guidelines.md b/src/site/markdown/customizing/rule-guidelines.md deleted file mode 100644 index b779f4ec34..0000000000 --- a/src/site/markdown/customizing/rule-guidelines.md +++ /dev/null @@ -1,146 +0,0 @@ - - -# Rule Guidelines - -Or - Last touches to a rules - -Here is a bunch of thing to do you may consider once your rule is "up and running". - -## How to define rules priority - -Rule priority may, of course, changes a lot depending on the context of the project. -However, you can use the following guidelines to assert the legitimate -priority of your rule: - -1. **Change absolutely required.** Behavior is critically broken/buggy. -2. **Change highly recommended.** Behavior is quite likely to be broken/buggy. -3. **Change recommended.** Behavior is confusing, perhaps buggy, and/or against standards/best practices. -4. **Change optional.** Behavior is not likely to be buggy, but more just flies in the face of - standards/style/good taste. -5. **Change highly optional.** Nice to have, such as a consistent naming policy for package/class/fields... - -For instance, let's take the ExplicitCallToGC rule ("Do not explicitly trigger a garbage collection."). -Calling GC is a bad idea, but it doesn't break the application. -So we skip priority one. However, as explicit call to gc may really hinder application performances, -we set for the priority 2. - -## Code formatting - -We try to keep a consistent code formatting through out PMD code base to ensure an easier maintenance and also -make the diff send to the mailing list as readable as possible. - -In order to ensure this, we use a PMD specific Eclipse formatter configuration: -**tools/config/eclipse-code-formatter-settings.xml**. Please do not forget to uses it -before committing or any source code! - -## Correctness - -You should try to run the rule on a large code base, like the jdk source code for instance. -This will help ensure that the rule does not raise exceptions when dealing with unusual constructs. - -If your rule is stateful, make sure that it is reinitialized correctly. The "-stress" command line -option can be used as the files will then not be ordered but processed randomly. -Running pmd with the "-stress" option several times and sorting the text output should produce -identical results if the state information is correctly reset. - -## Performance issues - -When writing a new rule, using command line option "-benchmark" on a few rules can give an indication -on how the rule compares to others. -To get the full picture, use the rulesets/internal/all-java.xml ruleset with "-benchmark". - -Rules which use the RuleChain to visit the AST are faster than rules which perform manual visitation of the AST. -The difference is small for an individual Java rule, but when running 100s of rules, it is measurable. -For XPath rules, the difference is extremely noticeable due to Jaxen overhead for AST navigation. -Make sure your XPath rules using the RuleChain. - -(TODO How does one know except by running in a debugger or horrendous performance?). - -## Adding test cases ... - -### ... for a rule I want to submit (in a patch) - -In the test directory (src/test/java), you'll find all the unit tests for PMD. In the -proper package (for instance, net.sourceforge.pmd.lang.java.rule.basic, for -rules from the basic rulesets), you'll find a test suite such as this: - - public class BasicRulesTest extends SimpleAggregatorTst { - - @Before - public void setUp() { - addRule("java-basic", "AvoidDecimalLiteralsInBigDecimalConstructor"); - addRule("java-basic", "AvoidMultipleUnaryOperators"); - addRule("java-basic", "AvoidThreadGroup"); - ... - -Suppose you want to add tests for a new rule of yours, called "MyNewRule". -Just add the proper line in this suite: - - public void setUp() { - ... - addRule("java-basic", "MyNewRule"); - ... - } - -And add in the appropriate xml subpackage in src/test/resources (for instance, -net.sourceforge.pmd.lang.java.rule.basic.xml). There you should find a XML file -for each rule, the syntax is pretty obvious: - - - - call super - 1 - - - - -### ... for something too specific, that I won't be able to submit - -In this case, you can still use the PMD test framework, as it is shipped in PMD. Follow -the previous instructions to right your test case, and simply create our own RulesTest using -the SimpleAggregatorTst: - - package too.specific.to.submit; - - import org.junit.Before; - import net.sourceforge.pmd.testframework.SimpleAggregatorTst; - - public class SpecificRulesTest extends SimpleAggregatorTst { - - @Before - public void setUp() { - addRule("specific-rules.xml", "MySpecificRule"); - } - - public static junit.framework.Test suite() { - return new junit.framework.JUnit4TestAdapter(SpecificRulesTest.class); - } - - } - -_Note the following PMD dependencies are required to run the test:_ - -1. asm -2. jaxen - -## Code quality - -If you want to contribute a java rule to PMD, you should run PMD on it -(Using the dogfood rulesets), to ensure that you rule follow the rules defined by the PMD community. - -Also note, that if this is not a strong policy, most developers uses the berkeley braces syntax. - -## Committing - -Before committing changes, make sure the verify phase of a maven build succeeds without test failures. -Drink a beer while you wait for it to finish. - -Then read the output to make sure no fatal errors are present. diff --git a/src/site/markdown/customizing/xpathruletutorial.md b/src/site/markdown/customizing/xpathruletutorial.md deleted file mode 100644 index cb7c35c796..0000000000 --- a/src/site/markdown/customizing/xpathruletutorial.md +++ /dev/null @@ -1,166 +0,0 @@ - - -# XPath Rule tutorial - -Writing PMD rules with XPath can be a bit easier than writing rules with Java code. -Here's an introduction on how to do that. - -## Introduction - -PMD provides a very handy method for writing rules by writing an XPath query. -When the XPath query finds a match, a violation is added to the report. This document -focuses on XPath rules. You can go [here](howtowritearule.html) for more -information about writing a rule. - -## What is the Abstract Syntax Tree (AST)? - -From [FOLDOC](http://foldoc.org/abstract+syntax+tree) an AST is - -> A data structure representing something which has been parsed, often used as -> a compiler or interpreter's internal representation of a -> program while it is being optimised and from which code -> generation is performed. - - -In our context, this means that we basically have a tree representation -of the Java source file. This tree can viewed as a structured document - just like XML. -And since it's conceptually similar to XML, it can be queried with XPath to find a pattern. - -## Using Designer - -PMD comes with a handy tool that you will love if you want to write an XPath rule. -Designer, runnable from a script in bin/, is a very simple and useful utility for writing rules. - -The basic steps involved in writing XPath rules are these: - -1. Write a simple Java example source snippet in Designer -2. See the AST for the class you wrote -3. Write an XPath expression that matches the violation you are searching -4. Modify the Java class and go back to previous step to refine the XPath expression - -## Simple XPath expressions - -This section provides hands-on examples of XPath queries over the AST. -You will probably find this section more useful if you follow it with -Designer and copy/paste the examples. - -Copy the following Java source code to Designer: - - public class a { - int fOne; - int fTwo; - - private void run() { - int one; - int two; - } - } - -Let's assume you want to match something on class variable names. You -see in the ASTVviewer that VariableDeclaratorId contains the variable name - in XML terms, -the name is in the `@Image` attribute. So you try an -XPath expression as follows: - - //VariableDeclaratorId - -If you try this expression you'll see that variables declared in -methods are also matched. A more precise expression for matching field -declarations is, well, using the FieldDeclaration node. This expression -matches only the two fields declared in the class: - - //FieldDeclaration - -In a similar way, you can match only local variables with this expression - - //LocalVariableDeclaration - -With local variables we need to be more careful. Consider the following class: - - public class a { - private void run() { - final int one; - int two; - - { - int a; - } - } - } - -Local variable declarations will match 'a', since it is a perfectly -legal Java local variable. Now, a more interesting expression is -to match variables declared in a method, and not on an internal block, -nor in the class. Maybe you'll start with an expression like this: - - //MethodDeclaration//LocalVariableDeclaration - -You'll quickly see that all three local variables are matched. A possible -solution for this is to request that the parent of the local variable -declaration is the MethodDeclaration node: - - //LocalVariableDeclaration[name(../../..) = 'MethodDeclaration'] - -## Matching variables by name - -Let's consider that we are writing rules for logger. Let's assume we -use the Java logging API and we want to find all classes that have more -than one logger. The following expression returns all variable declarations -whose type is 'Logger'. - - //VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']] - -Finding a class with more than one logger is quite easy now. This -expression matches the classes we are looking for. - - TypeDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']])>1] - -But let's refine this expression a little bit more. Consider the following class: - - public class a { - Logger log = null; - Logger log = null; - int b; - - void myMethod() { - Logger log = null; - int a; - } - class c { - Logger a; - Logger a; - } - } - -With this class we will only be matching one violation, when we -probably would have wanted to produce two violations (one for each class). -The following refined expression matches classes that contain more than one logger. - - //ClassOrInterfaceBodyDeclaration[count(//VariableDeclarator[../Type/ReferenceType/ClassOrInterfaceType[@Image='Logger']])>1] - -Let's assume we have a Factory class, that could be always declared final. -We'll search an xpath expression that matches all declarations of Factory -and reports a violation if it is not declared final. -Consider the following class: - - public class a { - Factory f1; - - void myMethod() { - Factory f2; - int a; - } - } - -The following expression does the magic we need: - - //VariableDeclarator - [../Type/ReferenceType/ClassOrInterfaceType - [@Image = 'Factory'] and ..[@Final='false']] - -I must recommend at this point that you experiment with Designer putting -the final modifier to the Factory and verifying that the results produced -are those expected. - -Finally, for many more details on writing XPath rules, pick up [PMD Applied](http://pmdapplied.com/)! diff --git a/src/site/markdown/index.md.vm b/src/site/markdown/index.md.vm deleted file mode 100644 index c955192794..0000000000 --- a/src/site/markdown/index.md.vm +++ /dev/null @@ -1,48 +0,0 @@ - - -Welcome to PMD -============== - -PMD scans source code in Java and other languages and looks for potential problems like: - -* Possible bugs - empty try/catch/finally/switch statements -* Dead code - unused local variables, parameters and private methods -* Suboptimal code - wasteful String/StringBuffer usage -* Overcomplicated expressions - unnecessary if statements, for loops that could be while loops -* Duplicate code - copied/pasted code means copied/pasted bugs - -Download --------- - -You can **[download everything from here][1]**, and you can get an overview of all the rules for -e.g. Java at the [rulesets index][2] page. - -PMD is [integrated][3] with JDeveloper, Eclipse, JEdit, JBuilder, BlueJ, CodeGuide, -NetBeans/Sun Java Studio Enterprise/Creator, IntelliJ IDEA, TextPad, Maven, Ant, Gel, JCreator, and Emacs. - -Changelog ---------- - -* See [What's new in PMD ${project.version}][4] -* Older versions: [Old Changelogs][5] - -Future releases ---------------- - -The next version of PMD will be developed in parallel with this release. We will release additional bugfix -versions as needed. - -A [snapshot][6] of the web site for the new version is generated daily by our continuous integration server. - -Maven packages are also generated regularly and uploaded to [Sonatypes OSS snapshot repository][7]. - - -[1]: https://sourceforge.net/projects/pmd/files/${project.version}/ -[2]: pmd-java/rules/index.html -[3]: usage/integrations.html -[4]: overview/changelog.html -[5]: overview/changelog-old.html -[6]: http://pmd.sourceforge.net/snapshot -[7]: https://oss.sonatype.org/content/repositories/snapshots/net/sourceforge/pmd/pmd/ diff --git a/src/site/markdown/overview/bestpractices.md b/src/site/markdown/overview/bestpractices.md deleted file mode 100644 index 2b064af9bc..0000000000 --- a/src/site/markdown/overview/bestpractices.md +++ /dev/null @@ -1,42 +0,0 @@ - - -# Best Practices - -## Choose the rules that are right for you - -Running every ruleset will result in a huge number of rule violations, most of which will be unimportant. -Having to sort through a thousand line report to find the few you're really interested in takes -all the fun out of things. - -Instead, start with some of the obvious rulesets - just run [unusedcode][1] and fix any unused locals and fields. -Then, run [empty][8] and fix all the empty `if` statements and such-like. After that, take [unnecessary][9] -and fix these violations. Then, run [basic][2] and fix the remaining violations. -Then peruse the [design][3] and [controversial][4] rulesets and use the ones -you like [via a custom ruleset][5]. - -## PMD rules are not set in stone - -Generally, pick the ones you like, and ignore or [suppress][6] the warnings you don't like. It's just a tool. - -## PMD IDE plugins are nice - -Using PMD within your IDE is much more enjoyable than flipping back and forth -between an HTML report and your IDE. Most IDE plugins have the "click on the rule -violation and jump to that line of code" feature. Find the PMD plugin for your IDE, install it, -and soon you'll be fixing problems much faster. - -Suggestions? Comments? Post them [here][7]. Thanks! - - -[1]: ../pmd-java/rules/index.html#Unused_Code -[2]: ../pmd-java/rules/index.html#Basic -[3]: ../pmd-java/rules/index.html#Design -[4]: ../pmd-java/rules/index.html#Controversial -[5]: ../customizing/howtomakearuleset.html -[6]: ../usage/suppressing.html -[7]: https://github.com/pmd/pmd/issues -[8]: ../pmd-java/rules/index.html#Empty_Code -[9]: ../pmd-java/rules/index.html#Unnecessary - diff --git a/src/site/markdown/overview/credits.md b/src/site/markdown/overview/credits.md deleted file mode 100644 index f1a55d60b3..0000000000 --- a/src/site/markdown/overview/credits.md +++ /dev/null @@ -1,505 +0,0 @@ - - -# Credits - -## Committers - -* David Dixon-Peugh - PMD core, much of the early work on the grammar, initial Emacs plugin -* Philippe Herlin - Eclipse plugin, fixed bugs in RuleSetFactory -* Nascif Abousalh Neto - Emacs plugin -* [Tom Copeland](http://tomcopeland.blogs.com/) - PMD core, lead developer, JDeveloper plugin, initial Gel plugin, - initial jEdit plugin, IDEAJ integration, BlueJ extension -* Jiger Patel - jEdit plugin -* Alan Ezust - jEdit plugin -* Ole-Martin Mork - NetBeans plugin -* Miguel Griffa - PMD core, over a dozen rules, lots of documentation, and other improvements all over the place -* Allan Caplan - PMD core, six rules, lots of bugfixes and improvements to the PMD core -* Radim Kubacki - Netbeans plugin, OptimizableToArrayCallRule suggestion, bug reports -* Tomasz Slota - Netbeans plugin -* Andrey Lumyanski - Gel plugin -* Johan Nagels - PMD core, JSP support -* Brian Remedios - PMD core, properties subsystem, lots of CPD UI improvements, Eclipse plugin improvements -* Xavier Le Vourch - PMD core, numerous bug fixes, UselessStringValueOf, UnnecessaryWrapperObjectCreation, - SimplifyBooleanAssertion -* Sven Jacob - DFA subsystem, Eclipse plugin -* Wouter Zelle - Lots of bugfixes and cleanups, JUnit test XML design, introduced java.util.logging, BrokenNullCheck, - NonThreadSafeSingleton, DefaultPackage rule, UselessOverridingMethod, ProperLogger, AvoidPrintStackTrace, - SimplifyConditional -* Ryan Gustafson - PMD core, assists with Eclipse plugin -* Torsten Kleiber - JDeveloper plugin -* Romain Pelisse - Various bugfix patches, restructured CPD tokenizers, patch to remove redundant rule, - added Fortran tokenizer, DoNotExtendJavaLangError, JspEncoding, MDBAndSessionBeanNamingConvention, - RemoteSessionInterfaceNamingConvention, LocalInterfaceSessionNamingConvention, LocalHomeNamingConvention, - RemoteInterfaceNamingConvention, AvoidFinalLocalVariable, ClassWithOnlyPrivateConstructorsShouldBeFinal, - TooManyStaticImports, DoNotCallSystemExit, StaticEJBFieldShouldBeFinal - -## Committers emeritus - -* Gunnlaugur Thor Briem - NetBeans plugin, Maven build script fixes, bug report on JavaCC parser's use - of java.lang.Error -* [David Craine](http://dcraine.blogspot.com/) - JBuilder plugin -* Tom Burke - Eclipse plugin -* Alex Chaffee - various bugfixes and features -* Siegfried Goeschl - original Maven plugin, various bugfixes and features -* Don Leckie - The PMD GUI -* [Rich Kilmer](http://richkilmer.blogs.com/) - logo design -* Paul Kendall - various bugfixes and features -* Colin Wilson-Salt - NetBeans plugin team -* [Brant Gurganus](http://gurganus.name/brant/) - JCreator integration, Swing GUI work - -## Significant contributors - -* Pieter Vanraemdonck - JSP grammar/integration/documentation, DontNestJsfInJstlIteration, NoLongScripts, - NoScriptlets, NoInlineStyleInformation, NoClassAttribute, NoJspForward -* Raik Schroeder - data flow analyis layer, YAHTMLRenderer -* Steve Hawkins - rewrite of CPD based on Karp-Rabin string matching -* Daniel Sheppard - XPath engine integration concept and implementation, advice on Jaxen extension function naming -* Brian Ewins - complete rewrite of CPD based on the Burrows-Wheeler transform, fixed DocumentNavigator bug - -## Contributors - -* Andy Throgmorton - New XPath getCommentOn function, new rule DontCallThreadRun, fix for rule UseArraysAsList -* Nicolas Dordet - Fixed an issue on CloseResource -* Juan Jesús García de Soria - Rework CPD algorithm -* Sergey Pariev - Fixed an ugly ArrayIndexOutOfBoundsException in CPD for Ruby -* Chris Heister - Reported and noted proper fix for bug in IDEAJ renderer operations -* Ralf Wagner - Reported bug in UselessOperationOnImmutable, reported and noted proper fix for broken XSLT -* Caroline Rioux - Reported bug in ImmutableField -* Miroslav Šulc - Reported bug in CloneMethodMustImplementCloneable -* Thomas Steininger - Noticed redundant rule -* Thomas Leplus - Contributed new rules LogicInversion, ExtendsObject, UselessParentheses, EmptyInitializer, - EmptyStatementBlock, CheckSkipResult.Rewrote UselessStringValueOf, nice patch for ClassCastExceptionWithToArray -* Paul Sundling - A nice documentation patch for ruleset links -* Matt Koch - Added more detail to PMD XML report -* Richard Hands - Fixed CPD symlink confusion -* Oleg Skrypnyuk - reported a Java 1.5 grammar bug -* Jeff Campbell - Found bug and suggested fix for problem with XMLRenderer and SuppressWarnings("PMD") annotations -* Kris Jurka - CPD patch to accept ".C" as a filename extension for C/C++ files -* Florian Deissenboeck - reported several Java 1.5 grammar bugs -* Maarten ter Huurne - BooleanGetMethodName, AddEmptyString, Noticed mispeling in AvoidArrayLoops rule -* Lukas Theussl - Patch to bring Maven configuration files up to date -* Jason Bennett - Rewrite of annotation-based warning suppression to allow for rule-specific suppression, - noticed useless line in XSLT scripts, fix for UnnecessaryLocalBeforeReturn, wrote NPathComplexity rule, - patches to improve CyclomaticComplexity rule, Implemented: UseCollectionIsEmpty, NcssTypeCount, NcssMethodCount, - NcssConstructor, Patch to detect comparison with new Object -* Brent Fisher - Fixed report backslash bug, SummaryHTML report improvements -* Larry Brigman - Reported symlink bug in CPD -* Harald Rohan - Reported bug in CPD GUI -* Stephan Classens - Patch for file closing bug, noted missing varargs setting in ASTFormalParameter -* piair - Implemented StringBufferInstantiationWithChar, AvoidUsingOctalValues -* Christopher Eagan - Reported bug in VariableNamingConventions -* [Fabio Insaccanebbia](http://www.livejournal.com/users/insac/) - Improvement for UseArraysAsList, - UnusedNullCheckInEquals, MisplacedNullCheck, UselessOperationOnImmutable, AvoidArrayLoops, UseArraysAsList, - AvoidConstantsInterface, AvoidDecimalLiteralsInBigDecimalConstructor, ClassCastExceptionWithToArray, - BigIntegerInstantiation -* Stefan Seidel - Reported Java 1.5 parsing bug -* Aaron Optimizer Digulla - Tweaks to pmd.bat -* Peter Van de Voorde - Rewrote the 'create rule XML' functionality in the designer utility -* Josh Devins - Reported bug with annotation parsing -* Alan Berg - Reported bug in Ant task -* George Thomas - Wrote AvoidRethrowingException rule, new AvoidLosingExceptionInformation rule -* Robert Simmons - Reported bug in optimizations package along with suggestions for fix -* Brian Remedios - display cleanup of CPD GUI, code cleanup of StringUtil and various rules, - cleanup of rule designer, code cleanup of net.sourceforge.pmd.ant.Formatter.java, - code improvements to Eclipse plugin, created AbstractPoorMethodCall and refactored UseIndexOfChar -* Max Tardiveau - A nice XML to HTML stylesheet for CPD. -* Ernst Reissner - reported IdempotentOperations bug, reported CloneThrowsCloneNotSupportedException bug, - reported Java 1.5 parsing bug, suggested InstantiationToGetClass, bug reports for - UnusedPrivateField/CloseConnectionRule/ConstructorCallsOverridableMethodRule, - and bug report and documentation suggestions for UseSingletonRule -* Maarten Coene - bug report for UnnecessaryConversionTemporary -* Jorn Stampehl - Reported bug in UnusedModifier, reported and fixed bugs in - JUnitTestsShouldContainAsserts/CyclomaticComplexity/TooManyFields, noticed redundancy of ExplicitCallToFinalize, - reported bug in AvoidCallingFinalize, reported bug in JUnitAssertionsShouldIncludeMessage, - reported bug in bug report on JUnitTestsShouldContainAsserts -* Ulrich Kriegel - reported Ant task documentation bug -* Jarkko Hietaniemin - rewrote most of cpd.sh, many C grammar improvements, several CPD documentation suggestions, - noted missing CPD scripts in binary release -* Adam Zell - Reported bug in UselessOverridingMethod -* Daniel Serodio - Reported bug in ExceptionSignatureDeclaration -* John Redford - Reported bug in AvoidProtectedFieldInFinalClass -* D'Arcy Smith - Reported bug in UncommentedEmptyConstructor, reported missing RuleViolation methods -* Paul Field - Fixed bug in MissingBreakInSwitch, reported a bug in DontImportJavaLang -* Attila Korompai - A nice patch to add messages to the NOPMD feature -* Levent Gurses - Suggested JSP support for the copy/paste detector -* Neil Cafferkey - Reported a typo in AssignmentInOperand -* Noel Grandin - bug report for ImmutableField, bug report for MissingStaticMethodInNonInstantiatableClass, - bug report for MissingBreakInSwitch, EqualsNull rule, bug report for IfElseStmtsMustUseBracesRule -* Olaf Heimburger - wrote the UseProperClassLoader rule, code changes to get JDeveloper plugin working - under JDev 10.1.3 EA, reported a possible NPE in ReportTree -* Mohammad Farooq - Reported new JavaNCSS URL -* Jeff Jensen - Reported missing XML schema references in documentation, wrote new XML schema, reported missing - schema refs in example rulesets, suggested posting XML schema on PMD site, discussion of - 'comments in catch block' feature, suggested description attribute in property element -* Christopher Stach - bug report for VariableNamingConventions, bug report for CallSuperInConstructor, - many bug reports for rules that didn't handle Java 1.5 constructs -* Matthew Harrah - noticed missing element in UseCorrectExceptionLogging definition, script bug report -* Mike Kaufman - Reported abug in UnnecessaryCaseChange -* [Elliotte Rusty Harold](http://www.cafeaulait.org/) - reported bug in UseAssertSameInsteadOfAssertTrue, - suggested creating a new ruleset containing rules in each release, UncommentedEmptyConstructor suggestions, - noted missed case for UnusedFormalParameter, documentation suggestions, - reported mistake in UnnecessaryLocalBeforeReturn message, - bug report 1371757 for misleading AvoidSynchronizedAtMethodLevel example, - bug report 1293277 for duplicated rule messages, bug report for ConstructorCallsOverridableMethod, - suggestion for improving command line interface, mispeling report, suggestion for improving Designer - startup script, "how to make a ruleset" documentation suggestions, noticed outdated Xerces jars, - script renaming suggestions, UseLocaleWithCaseConversions rule suggestion -* David Karr - reported stale XPath documentation -* Dawid Weiss - Reported bug in UnusedPrivateMethod -* Shao Lo - Reported bug in CPD -* Mathieu Champlon - Added language support to the CPD Ant task -* Uroshnor - Reported bug in UseNotifyAllInsteadOfNotify -* Jan Koops - Noted missing data in MemberValuePair nodes, bug report for JBuilder plugin -* [Will Sargent](http://tersesystems.com/) - Implemented AvoidThreadGroup, AvoidThrowingCertainExceptionTypesRule, - AvoidCatchingNPERule, ExceptionAsFlowControlRule, URL updates for 'Similar projects' page -* Benoit Xhenseval - noted Maven plugin bug (http://jira.codehaus.org/browse/MPPMD-24), - bug report for UnusedPrivateMethod, suggestion to add elapsed time to XML report, - bug report for ImmutableField, many bug reports (with good failure cases!), Ant task patch and bug report, - XSLT patch, suggestion for improving XML report -* Barak Naveh - Reported and fixed bug in CallSuperInConstructor -* Bhatia Saurabh - Reported a grammar bug, reported a bug in UseStringBufferLength -* Chris Erskine - found bad link, documentation suggestions -* mhilpert - Reported bugs in UseIndexOfChar and LoggerIsNotStaticFinal -* David Corley - Priority filtering XSLT, reported release packaging problem, implemented nifty - Javascript folding for XML report, [demo is here](http://tomcopeland.blogs.com/juniordeveloper/2005/12/demo_of_some_ni.html), - suggestion for min priority on the command line -* Jon Doh - Reported parser bug -* Brian R - suggestions for improving UseIndexOfChar, documentation suggestion -* Didier Duquennoy - bug reports for InefficientStringBuffering/ConsecutiveLiteralAppends/AppendCharacterWithChar, - several bug reports for InefficientStringBuffering, bug report for ImmutableField, suggestions for - improving Benchmark utility, bug report for InefficientStringBuffering, bug report for - AvoidConcateningNonLiteralsInStringBuffer, reported a missed hit for EqualsNull, bug report for - MissingStaticMethodInNonInstantiatableClass, pmd-netbeans feedback -* Paul Smith - patch to fix Ant task 'minimum priority' attribute -* Erik Thauvin - reported IDEA integration problem -* John Kenny - reported bug in ConsecutiveLiteralAppends -* Tom Judge - patch for fix to C/C++ multiline literal support for CPD, patch for including .cc files in - C++ CPD checks, patch for JDK compatibility problems -* Sean Mountcastle - reported documentation bug -* Greg Broderick - provided patch for 'minimum priority' support -* George Sexton - Bug report 1379701 for CompareObjectsWithEquals, suggested new rule for Additional String - Concatenation Warnings in StringBuffer. -* Johan Stuyts - improvements to UncommentedEmptyConstructor, nice patch for UncommentedEmptyConstructor and - UncommentedEmptyMethod, patch to allow empty catch blocks with comments in them, patch to clean up build environment -* Bruce Kelly - bug report 1378358 for StringInstantiation, bug report 1376756 for UselessOverridingMethod, - bug report 1376760 for InefficientStringBuffering -* Isaac Babsky - tweak for pmd.bat -* Hendrik Maryns - reported bug 1375290 for SuppressWarnings facility -* [Wim Deblauwe](http://www.jroller.com/page/Fester) - suggested UseAssertNullInsteadOfAssertTrue, - bug report 1373510 for UseAssertSameInsteadOfAssertTrue, suggested putting property names/values in generated docs, - UselessOverridingMethod, reported bug in JUnitTestsShouldContainAsserts, - front page and "how to make a ruleset" patches, noted problems with web site rule index, - bug report for JUnitTestsShouldContainAsserts, Clover license coordination and implementation, - UseCorrectExceptionLogging, coordinated and coded a much nicer asXML() implementation, - suggested cleanup of UnusedFormalParameter, Javadoc patch, SystemPrintln bug report, - helped get Ant task and CLI squared away with Java 1.5 params, Java 1.5-specific bug reports, - suggested improvements for ExceptionSignatureDeclaration -* Sean Montgomery - bug report 1371980 for InefficientStringBuffering -* Jean-Marc Vanel - suggested enhancements to the PMD scoreboard -* Andriy Rozeluk - suggested UseStringBufferLength, bug report 1306180 for - AvoidConcatenatingNonLiteralsInStringBuffer, reported bug 1293157 for UnusedPrivateMethod, - suggested UnnecessaryCaseChange, bug report for SimplifyConditional, suggested UnnecessaryLocalBeforeReturn, - suggestions for improving BooleanInstantiation, UnnecessaryReturn, AvoidDuplicateLiterals RFEs and bug reports, - various other RFEs and thoughtful discussions as well -* Bruno Juillet - suggested reporting suppressed warnings, bug report for missing package/class/method names, - patch for Ant task's excludeMarker attribute, bug report on ruleset overrides -* Derek Hofmann - suggestion for adding --skip-duplicate-files option for CPD, bug report for CPD skipping header - files when in C/C++ mode -* Mark Holczhammer - bug report for InefficientStringBuffering -* Raja Rajan - 2 bug reports for CompareObjectswithEquals -* Jeff Chamblee - suggested better message for UnnecessaryCaseChange, bug report for CompareObjectsWithEquals -* Dave Brosius - suggested MisleadingVariableName rule, a couple of nice patches to clean up some string handling - inefficiencies, non-static class usages, and unclosed streams/readers - found with Findbugs, I daresay :-) -* Chris Grindstaff - fixed SWTException when Eclipse plugin is run on a file with syntax error -* Eduard Naum - fixed JDK 1.3 runtime problems in Eclipse plugin -* Jacques Lebourgeois - fix for UTF8 characters in Eclipse plugin -* dvholten - suggestions for improving OverrideBothEqualsAndHashcode, formatting suggestions for HTML report, - test cases for ConstructorCallsOverridableMethod, reported several NullAssignment bugs -* Brian Duff - helped get Oracle JDeveloper plugin working -* Sivakumar Mambakkam - bug report 1314086 for missing name in SimpleRuleSetNameMapper -* Rodrigo Ruiz - bug report 1312723 for FieldDeclaration nodes inside interfaces, bug report 1312754 for - pmd.bat option handling, bug report 1312720 (and code fix!) for DefaultPackage, bug report 1309235 for TooManyFields -* [Lori Olson](http://blogs.teamb.com/LoriOlson/) - JBuilder plugin suggestions and prerelease tests, - found copy/paste bug in rule descriptions -* Thomas Dudziak - bug report 1304739 for StringInstantiation -* Pieter Bloemendaal - reported JDK 1.3 parsing bug 1292609, command line docs bug report, - bug report for UnusedPrivateMethod, found typo in ArrayIsStoredDirectly, bug report for - AvoidReassigningParametersRule -* shawn2005 - documentation bug report -* Andrew Taylor - bug report for StringInstantiation -* S. David Pullara - bug report for AvoidConcateningNonLiteralsInStringBuffer, bug report for ImmutableField -* Maarten Bodewes - bug report for ImmutableField -* Peter Frandsen - PackageCase rule, NoPackage rule -* Noureddine Bekrar - French translation of some PMD documentation -* Martin Jost - bug report for JDeveloper plugin -* Guillaume Boudreau - patches to fix problems with CPD's FileFinder and NTFS and SCCS -* Sylvain Veyrie - bug report for MethodReturnsInternalArray -* Randy Ray - bug report for ArrayIsStoredDirectly -* Klaus - Suggestion for improving UseSingleton -* Nicolai Czempin - Bug report for UnnecessaryParentheses, various rule suggestions, additional PMD backronyms -* Kevin Routley - reported Ant task dependency problem, reported problems with RuleSetFactory unit tests -* Dennis Klemann - noted that errors were missing from text report, reported Java 1.5 parsing bug with - ExceptionSignatureDeclaration, reported fix for pmd.bat problem -* Tor Norbye - Suggested CompareObjectsWithEquals -* Thomas Skariah - bug reports for MethodArgumentCouldBeFinal and AvoidReassigningParameters -* Tom Parker - bug report for MethodReturnsInternalArray, found missed case in NullAssignment, suggested addition - to UnnecessaryBooleanAssertion, suggested splitting up AvoidThrowingCertainExceptionTypes, - AvoidInstantiatingObjectsInLoops bug report, AtLeastOneConstructor bug report -* Ian Flanigan - reported CPD JNLP breakage -* Glen Cordrey - Reported bug involved JavaCC string handling -* Oto 'tapik' Buchta - Patched XMLRenderer for UTF8 support -* Arent-Jan Banck - Reported bug with Java 1.5 annotation handling -* Fred Hartman - Reported exact location of bug in TooManyFields, fixed bug in UnnecessaryBooleanAssertion -* Andreas Ehn - Reported bug with Java 1.5 generics parsing -* Eric Olander - SingularField, SimplifyConditional fix, UseStringBufferForStringAppends, CollapsibleIfStatements, - AvoidInstanceofChecksInCatchClause, AssignmentToNonFinalStatic rule, nice patch for DFAPanel cleanup, AvoidProtectedFieldInFinalClass, ImmutableFieldRule, noticed missing image in Postfix nodes -* [Tomas Gustavsson](http://sourceforge.net/users/anatom/) - reported pmd-web breakage -* Payal Subhash - Tweaks to CSVRenderer -* Christophe Mourette - Reported JDK 1.3 problem with XMLRenderer -* Alex Givant - caught documentation bug -* [Luke Francl](http://justlooking.recursion.org/) - suggested UnnecessaryParentheses rule, numerous **high quality** - feature suggestions and bug reports -* David Hovemeyer - reported missing labelled stmt images, a nice patch to let PMD process code in jar/zip files -* Peter 'Bruno' Kofler - reported bug #1146116 for JUnitTestsShouldIncludeAssert -* Zev Blut - nice patch to add Ruby support to CPD -* Christopher Judd - a nice patch to the XSLT that adds a summary -* John Meagher - suggested the rule 'MissingSerialVersionUID' and provided the implementation for it -* John Austin - patch to fix mispeling in Eclipse plugin message -* Paddy Fagan - reported bug in StatisticalRule -* Leszek Migdal - reported documentation mistake for Eclipse plugin -* Hakan Civelek - an order-of-magnitude optimization to the SystemOutPrintln rule -* John Heintz - Added "any language" support to CPD. -* Harald Gurres - cleaned up the symbol table code with a very nice patch -* Matthias Kerkhoff - CPD suggestions, several bug reports -* Chris Riesbeck - identified some dead code in RuleSet -* Lars Gregori - reported a bug in the Ant task docs -* [Todd Wright](http://freshmeat.net/~toddwright/) - reported bug in EmptyStatementNotInLoop, XPath port of - AtLeastOneConstructorRule, ConfusingTernaryExpression rule, reported missing ASTUnaryExpressionNotPlusMinus nodes -* [Conrad Roche](http://derupe.blogspot.com/) - UnusedModifier bug report, other bug reports -* Mike Thome - NOPMD implementation concept, BadComparisonRule suggestion -* Ken Foskey - C++ parser bug report, cpd.sh -* ehowe - a nice patch to include rule priority in the XML report -* aryanto - reported a broken reference in the 'favorites' ruleset. -* Archimedes Trajano - suggested SimpleDateFormatNeedsLocale -* Joerg Kurt Wegner - bug report for UnusedLocalVariable -* Bruno - Reported bug with TooManyFields, SuspiciousEqualsMethodName -* Philippe Couton - bug report for ExceptionAsFlowControl, OverrideBothEqualsAndHashcodeRule bug report, - UseSingletonRule improvements, JUnitStaticSuiteRule improvements -* Paul Rowe - suggestion for improving MethodWithSameNameAsEnclosingClass, bug reports for - SimplifyBooleanExpressions and UnusedLocalVariable -* Enno Derksen - enhancements to VariableNamingConventionsRule -* Michael Haggerty - bug reports for FinalizeDoesNotCallSuperFinalize and UnusedModifier -* Phil Shaw - documentation suggestions -* Sreenivasa Viswanadha - reminded me to use BufferedInputStreams, grammar cleanup for Ctrl-Z problem -* Austin Moore - Integration with Omnicore's CodeGuide IDE -* Matt Inger - CloneMethodMustImplementCloneable, CloneThrowsCloneNotSupportedException -* Morgan Schweers - Javascript highlighter for the PMD scoreboard -* Brandon Franklin - bug report for BeanMembersShouldSerializeRule, many PMD scoreboard ideas -* Bertrand Mollinier Toublet - Bug report which led to platform character set encoding enhancement -* Choi Ki Soo - Found bug in XMLRenderer -* [Gero Wedemann](http://www.fh-stralsund.de/mitarbeiter/powerslave,id,264,nodeid,75.html) - Found bug in - RuleSetFactory XPath message variable substitution -* Adrian Papari - Wrote the PapariTextRenderer -* Curt Cox - some additions to the 'Similar Projects' page -* Michael Griffel - bug fix for XMLRenderer -* Doug Tillman - correction to finalizers.xml examples -* Luis Alberto Domínguez Ruiz - bug report for IfElseStmtsMustUseBracesRule -* Chad Loder - SuspiciousOctalEscapeRule, EmptyStatementNotInLoop, SuspiciousHashcodeMethodName, - NonCaseLabelInSwitchStatement, DefaultLabelNotLastInSwitchStmt, NonStaticInitializer, ExplicitCallToFinalize, - MethodWithSameNameAsEnclosingClassRuleTest, FinalizeDoesNotCallSuperFinalize, FinalizeOverloaded, - FinalizeOnlyCallsSuperFinalize, UnconditionalIfStatement, AvoidDollarSigns, EmptyStaticInitializer, - EmptyFinalizerMethod rule, DontImportSun rule, improvements to ASTBooleanLiteral -* Maik Schreiber - AccessNode bug report, other bug reports -* Lokesh Gupta - improvements to the AST viewer -* [Jesse Glick](http://www.oreillynet.com/cs/catalog/view/au/960?x-t=book.view) - improvements to - VariableNamingConventionsRule, patch for UnusedModifierRule, bug fix for VariableNameDeclarations rule, - an excellent discussion on the UnnecessaryConstructorRule -* Nicolas Liochon - CloneShouldCallSuperCloneRule implementation -* [Slava Pestov](http://factor-language.blogspot.com/) - Suggestions for jEdit plugin enhancements. -* Olivier Mengué - Diagnosed and patched XML report character encoding problems -* Hariolf Häfele - PMD-JDeveloper plugin bug reports -* [Vladimir Bossicard](http://www.bossicard.com/) - suggested AbstractNamingRule, test package - organization suggestions, VBHTMLRenderer, numerous feature requests and bug reports, several rule suggestions - derived from [JUnit-Addons](http://junit-addons.sf.net/), evangelism :-) -* Ken Foskey - noticed bad link -* [Stephan Janssen](http://www.bejug.org/confluenceBeJUG/display/BeJUG/Stephan+Janssen) - - promoted PMD for [JJGuidelines](http://web.archive.org/web/20070701124257/https://jjguidelines.dev.java.net/) -* Ron Sidi - bug reports -* David Koontz - suggestions for tweaking PMD command line options -* Jeff Epstein - TextPad integration and tests -* Gabe Johnson - CloseConnectionRule -* Roelof Vuurboom - posted report of QStudio analysis of PMD -* Jeff Anderson - node finding utility code -* Boris Gruschko - regression test suites, nifty AST/XPath viewer -* Trevor Harmon - rewrote XSLT script -* [Vadim Nasardinov](http://philip.greenspun.com/shared/community-member?user_id=174176) - xdocs cleanup, - run.sh cleanup -* Sigiswald Madou - bug report -* Dan Tullis - bug report -* George Menhorn - CPD bug reports and suggestions -* Paul Roebuck - Ant build improvement, several bug reports -* Jon A. Maxwell - Bug report -* Erik Lee - Bug report -* Joerg K. Wegner - PMD scoreboard suggestions -* Chris Webster - fix (and test) for UnnecessaryConstructorRule, BooleanInstantiation rule -* Colin Simmonds - detailed bug reports -* [Trond Andersen](http://reassess.blogspot.com/) - AvoidCatchingThrowable, ExceptionSignatureDeclaration, - ExceptionTypeChecking -* Bernd Jansen - grammer modification -* Jarle Naess - bug report -* Jeff Anderson - VariableNamingConventionsRule, MethodNamingConventionsRule, ClassNamingConventionsRule -* Frank van Puffelen - documentation suggestions -* mcclain looney - patch for CPD GUI, bug reports -* Ralf Hauser - Various documentation suggestions, cygwin-run.sh -* Pablo Casado - Bug report for UseSingletonRule -* Frank Hardisty - BeanMembersShouldSerializeRule -* Randall Schulz - bug report for LooseCouplingRule -* Wim Bervoets - bug report for the PMD Ant task -* Niels Peter Strandberg - various tweaks to the PMD Swing UI -* Ian Shef - documentation updates, bug reports on the Gel IDE plugin -* Astro Jetson Jr - a tweak for the ShortVariableNameRule -* Paul King - a complete rewrite of the Gel plugin -* Gael Marziou - "exclude" rule feature request, bug reports -* Philippe T'Seyen - refactoring and cleanup of the CPD Ant task, an XML renderer (with unit tests!) for CPD -* Michael Montuori - bug reports on the Gel IDE plugin -* Michael Hosier - bug reports on the Gel IDE plugin -* Richard Jenson - CPD on Win32 troubleshooting -* Daniel Bruguier - CPD on Win32 troubleshooting -* Mario Claerhout - CPD optimizations and suggestions -* Sameer Nanda - CPD Ant task bug report -* Nanne Baars - grammar suggestions, rule suggestions -* Adam Nemeth - bug fixes for UnnecessaryConstructorRule -* [Andrew Glover](http://www.oreillynet.com/pub/au/1425) - the CPDTask, ExcessivePublicCountRule, - CouplingBetweenObjectsRule, ExcessiveImportsRule, documentation tweaks -* Robert Leland - bug report -* Carl Gilbert - AccessorClassGenerationRule, DoubleCheckedLockingRule, ConstructorCallsOverridableMethodRule, - bug reports, feature requests, and documentation improvements -* Dave Fuller - improved resource loading code (packaged in a nice diff, too!) -* David Whitmore - parser bug report -* David Campbell - detailed bugs reports, Ant task refactoring, documentation tweaks -* Michael Sutherland - bug report in IfStmtMustUseBracesRule -* Egon Willighagen - PMD scoreboard suggestion -* Adam Nemeth - bug report on missing final attribute for local variable declarations -* Frederic Harper - bug report and subsequent troubleshooting -* [Mats Henricson](http://www.henricson.se/mats/) - an XSLT script and several bug reports -* Martin Cooper - feature suggestions -* Bruce Mayhew - feedback on the jEdit plugin -* Juergen Ebert - feature suggestions and pmd-netbeans feedback -* J.D. Fagan - feature suggestions -* William McArthur - ForLoopShouldBeWhileLoop rule -* Ales Bukovsky - pmd-netbeans feedback -* [Stefan Bodewig](http://stefan.samaflost.de/blog) - bug report -* Sean Sullivan - rule suggestions -* Dale Vissar - rule suggestions -* [Alina Copeland](http://www.informatik.uni-trier.de/~ley/db/indices/a-tree/c/Copeland:Alina.html) - - PMD scoreboard formulas, pmd-dcpd optimizations -* Vincent Massol - bug reports, design suggestions, feature suggestions, Maven guidance -* Peter Donald - design suggestions -* Liam Holohan - bug reports -* Ralph Schaer - bug reports and verification -* Damian O'Neill - Ant task patches -* Sebastian Raffel - Great job on the Eclipse PMD perspective, new views and dataflow analysis support -* Ebu - Eclipse smoothed icons -* Jacques Lebourgeois - Eclipse fix malformed UTF-8 characters -* Chris Grindstaff - Eclipse fix SWTException when PMD is run on a file with syntax error -* jmichelberger - wrote Byte/Short/Long Instantiation migration rules -* Edwin Chan - Support for -auxclasspath for use with Type Resolution -* Jared Bunting - Patch to add ASTAnnotationMethodDeclaration to Java AST -* Lucian Ciufudean - RedundantFieldInitializerRule -* Andreas Dangel - GodClass and LawOfDemeter rules, several bugfixes and cleanup -* Riku Nykanen - patch improving TooManyMethods rule -* Tammo van Lessen - new rule GuardDebugLogging for Jakarta Commons Logging ruleset. -* Steven Christou - patch improving DoNotCallSystemExit rule -* Cd-Man - patch to improve CPD performance -* Suresh - new rule DontUseFloatTypeForLoopIndices -* Dinesh Bolkensteyn and SonarSource - Java 7 grammar support -* Tom Wheeler - contribute a launch script for CPD GUI -* Remi Delmas - change CPD CLI to return a non null value when code duplication is found. -* Victor Bucutea - Improved JSP parser to be less strict with not valid XML documents (like HTML). -* Prabhjot Singh - Fixed bug 3484404: Invalid NPath calculation in return statement. -* Roman - Fixed bug 3546093: Type resolution very slow for big project. -* Florian Bauer - Add C# support for CPD. -* Matthew Short - Support in CPD for IgnoreAnnotations and SuppressWarnings("CPD-START"). -* Simon Gijsen - contributing a PMD logo with a modern look. -* Yiannis Paschalidis - Fixed bug #968 Issues with JUnit4 @Test annotation with expected exception -* Jaroslav Snajberk - Make the comment required rule working. -* Mat Booth - #1109 Patch to build with Javacc 5.0 -* Stuart Turton - for PLSQL support. See also [pldoc](http://pldoc.sourceforge.net/) -* Andrey Utis - for adding Apache Velocity as a new language and writing up a - [howto for adding new languages](../customizing/new-language.html). -* Alan Hohn - for adding Standard and modified cyclomatic complexity rules -* Jan van Nunen - for adding CPD support for Matlab, Objective-C, Python, Scala and various bug fixes -* Juan Martín Sotuyo Dodero - for many bugfixes/pull requests improving Java grammar and performance - -## Organizations - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- AE for the JSP integration and especially for writing the JSP grammar. -
- DARPA for funding - the Ultra*Log and Cougaar - effort which spawned PMD. -
- SourceForge for providing hosting services for PMD. -
- RefactorIT for letting - their software be used free-of-charge on PMD code - (OpenSource - Community License) -
- QA-Systems for sending in some - handy utilities for PMD and shipping PMD inside their QStudio product -
- Vanward Technologies for - using PMD inside their Convergence product -
- Cenqua for - giving us a free Clover license and doing a nice FishEye run. -
- YourKit is kindly supporting open source projects with its full-featured Java Profiler. - YourKit, LLC is creator of innovative and intelligent tools for profiling - Java and .NET applications. Take a look at YourKit's leading software products: - YourKit Java Profiler and - YourKit .NET Profiler. -
- Bijzonder Bezig for giving the PMD logo a modern look. -
diff --git a/src/site/markdown/overview/future.md b/src/site/markdown/overview/future.md deleted file mode 100644 index 8e130ba075..0000000000 --- a/src/site/markdown/overview/future.md +++ /dev/null @@ -1,124 +0,0 @@ - - -# Future directions - -Want to know what's coming? Or, better, wanna contribute ? Here is the page listing what are our plans - -when we have ones, for the future of PMD. It also give you hints at part of the code we would like to clean - -that you may want to clean to contribute to the project! - -Of course, an easy way to contribute is too check out the [bug tracker][1] and see if you can fix some issues - -some could be quite easy, we simply have not the time to look at them all! - -At last, if you want to contribute, register on the [pmd-devel][2] mailing list, and come discuss with us! - -## Roadmap - -This roadmap contains all the different 'workshops' PMD's developers are working right now. - -* **Better symbol analysis**: See below. -* **Data Flow Analysis**: See below. -* **Code Cleanups**: See below. - -*Please note that, of course, there is no warranty about when those 'features' will be finished, if they ever are.* - -## Better symbol analysis - -Currently PMD only looks at one source file at a time. Instead, it should resolve symbols across classes. -This will eliminate some open bugs and enable a lot more rules to be written. However, it'll taken some doing, -because it'll require parsing of class files. Lots of work here. - -## Data flow analysis (DFA) - -Raik Schroeder, a graduate student at [Fachhochschule Stralsund][3] has written a DFA layer that should enable -us to write some more complicated rules - stuff like common subexpression elimination, loop invariant code motion -(and code hoisting suggestions), shrink wrapping, and partial redundancy elimination. The code is currently in CVS -in the net.sourceforge.pmd.dfa packages, and we're going through it now figuring out what rules we can write -that use it. We should be able to use it to simplify some current rules, as well. - -## Other changes we'll like to see... - -**These are things which really should be done, but just haven't been gotten to yet:** - -* Enhance Rule Designer to allow testing of the violation suppress Regex and XPath. -* Remove the type resolution specific rules. Merge these back into the - standard rules. In general, a Rule should use TR when it can, and fall - back on non-TR approach otherwise. No need for separate Rules for TR/non-TR. -* Reconcile the util.designer and util.viewer packages. Two versions of the - same thing. Designer is more up to date, but Viewer has a nice MVC design. -* Need a JUnit test to check for "dead" Rules, that is those not used by any RuleSet. -* Rule JUnit tests should verify the Test class follows expected naming - conventions just like the Rules need to. -* Do we have a rule to style check for multiple declarations and chained - assignments? (e.g. int a, b; int a = b = x;) - -These are food for thought, perhaps future items. If you think you'd like to -work on one of these, check with pmd-devel to see what the current thoughts -on the topic. - -* CPD needs work on use of Language. It currently is hardcoded to only - handled Java 1.4. Integrate CPD needs into core PMD where appropriate. - Otherwise, drive CPD behavior based off of core PMD, instead of duplicating - some logic. - -* Need a more flexible and powerful scheme for classifying files to various - Languages. At a minimum, should have the ability to specify which - file extensions you want to be used for a language (e.g. not everyone uses - .jsp for JSP extensions, some use .jspx, .xhtml, etc.). Also, consider - hooks into the LanguageVersionDiscoverer process for classifying a - File/String to a LanguageVersion of a specific Language, one could imaging - using a 'magic' system like Unix uses to tell different versions of files - apart based on actual content. - -* Should we change Node interface to something like 'Node<T extends Node<T>>', - and then declare the language specific node interfaces to be something like - 'JavaNode extends Node<JavaNode>'? This could allow anything on the Node - interface to return the language specific node type instead of generic - node. For example, ASTStatement.jjtGetParent() to return a JavaNode, - instead of a Node. This is a rather huge change, as the Node interface is - one of the pervasive things in the PMD code base. Is the extra work of using - the Node interface with properly with generics, worth the omission of - occasional some casting? - -* Should multiple Languages be able to claim a single source file? Imagine - XML format JSP file, for which you've defined a ruleset which uses JSP and - XML rules. Stating that certain XML rules also can map to the JSP language - extensions could be useful. This means Source file to LanguageVersion - mapping is not 1-1, but 1-many, we'd need to deal with this accordingly. - -* Additional changes to Rule organization within RuleSets as discussed on - [this forum thread][4]. - -* Figure out a way to allow Rules to deal with parentheses and blocks, which - introduce certain repetitive (and generally ignorable for most Rules) - structures into the AST tree. Some rules are making special effort - (e.g. ConfusingTernaryRule) to detect these AST patterns. Perhaps a - "normalized" AST structure can be created which will make the AST appear - consistent regardless of how many parens are presented, or how many blocks - have been created (e.g. default block inserted, duplicates collapsed). - This should be configurable on per Rule basis similar to TR and SymbolTable. - -## Code cleanups - -Some of the code is a bit sloppy: - -* RuleSetFactory is a mess. It needs to be refactored into something that has layers, or decorators, or something. -* Cleanups would be welcome for ConstructorCallsOverridableMethod and DoubleCheckedLocking -* The Designer GUI is a bit messed up; the bottom panes look funny. -* The grammar has some odd bits: - * BlockStatement has an odd hack for class definitions inside methods - * enumLookahead() seems like a bit of overkill, can it use Modifiers somehow? - * The whole "discardable node" thing seems wasteful - * Does ExtendsList need that 'extendsMoreThanOne' thing? - * ClassOrInterfaceBodyDeclaration has a monstrous lookahead to check for enums - * ClassOrInterfaceType gloms together dotted names... is that the right thing to do? - * Some complicated annotations are currently broken - - -[1]: http://sourceforge.net/p/pmd/bugs/ -[2]: http://sourceforge.net/mailarchive/forum.php?forum_name=pmd-devel -[3]: http://www.fh-stralsund.de/ -[4]: http://sourceforge.net/p/pmd/discussion/188194/thread/b840897c diff --git a/src/site/markdown/overview/license.md b/src/site/markdown/overview/license.md deleted file mode 100644 index 33a260b545..0000000000 --- a/src/site/markdown/overview/license.md +++ /dev/null @@ -1,253 +0,0 @@ - - -# License - -This product is licensed under a "BSD-style" license; see below for the full text. - -Part of this product (mostly the package net.sourceforge.pmd.lang.vm) -is licensed under the Apache License, Version 2.0; -see below for the full text. - -## BSD-style license - -
-Copyright (c) 2002-2009, InfoEther, Inc
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-    * The end-user documentation included with the redistribution, if
-      any, must include the following acknowledgement:
-      "This product includes software developed in part by support from
-      the Defense Advanced Research Project Agency (DARPA)"
-    * Neither the name of InfoEther, LLC nor the names of its
-      contributors may be used to endorse or promote products derived from
-      this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
- -## Apache License, Version 2.0 - -
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
-   APPENDIX: How to apply the Apache License to your work.
-
-      To apply the Apache License to your work, attach the following
-      boilerplate notice, with the fields enclosed by brackets "[]"
-      replaced with your own identifying information. (Don't include
-      the brackets!)  The text should be enclosed in the appropriate
-      comment syntax for the file format. We also recommend that a
-      file or class name and description of purpose be included on the
-      same "printed page" as the copyright notice for easier
-      identification within third-party archives.
-
-   Copyright [yyyy] [name of copyright owner]
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-
diff --git a/src/site/markdown/overview/meaning.md b/src/site/markdown/overview/meaning.md deleted file mode 100644 index 114b4acc45..0000000000 --- a/src/site/markdown/overview/meaning.md +++ /dev/null @@ -1,25 +0,0 @@ - - -# What does 'PMD' mean? - -We've been trying to find the meaning of the letters PMD - because frankly, we don't -really know. We just think the letters sound good together. - -However, in the spirit of the Computing Industry, we have come up with several "backronyms" to explain it. - -**PMD...** - -* Pretty Much Done -* Project Mess Detector -* Project Monitoring Directives -* Project Meets Deadline -* Programming Mistake Detector -* Pounds Mistakes Dead -* PMD Meaning Discovery (recursion, hooray!) -* Programs of Mass Destruction -* Programming Meticulous coDe -* [A 'Chaotic Metal' rock band name][1] - -[1]: http://www.myspace.com/prettymarydies diff --git a/src/site/markdown/overview/news.md b/src/site/markdown/overview/news.md deleted file mode 100644 index 6aca528a02..0000000000 --- a/src/site/markdown/overview/news.md +++ /dev/null @@ -1,92 +0,0 @@ - - -# PMD in the press - -## Sites/Articles about PMD - -* February 2012 - Romain Pelisse's lightning talk at FOSDEM 2012 about "PMD5: What can it do for you?". - [Video recording is available](http://video.fosdem.org/2012/lightningtalks/PMD5.webm). - -* May 2008 - Alan Berg's article on - [Free Software Magazine](http://www.freesoftwaremagazine.com/columns/destroy_annoying_bugs_part_1) - discusses FindBugs, PMD, and TFTP. - -* July 2007 - Ryan Slobojan's article on [InfoQ](http://www.infoq.com/news/2007/07/pmd) - discusses the PMD 4.0 release. - -* October 2006 -Alan Berg's article "Light On Java Code" in - [Software Testing and Performance Magazine [link broken]](http://www.stpmag.com/issues/stp-2006-10.pdf) - discusses static code analysis using FindBugs and PMD. - -* July 2006 - Paul Duvall's article "Automation for the people: Continuous Inspection" on - [developerWorks](http://www-128.ibm.com/developerworks/java/library/j-ap08016/index.html) discusses CPD. - -* June 2006 - Andrew Glover's article "In pursuit of code quality: Tame the chatterbox" on - [developerWorks](http://www-128.ibm.com/developerworks/java/library/j-cq06306/index.html?ca=drs-) - discusses PMD and JavaNCSS. - -* June 2006 - Tom Copeland's article "Static Electricity: Better Living with Static Code Analysis" in - [Better Software](http://tomcopeland.blogs.com/juniordeveloper/2006/06/a_pmd_analysis_.html) discusses - PMD/CPD analyses of Azureus and Columba. - -* April 2006 - John Ferguson Smart's article "PMD Squashes Code Bugs" on - [DevX](http://www.devx.com/Java/Article/31286) discusses PMD and the Eclipse plugin. Lots of screenshots! - -* November 2005 - Mike Clark's article "Staying Out of Code Debt" on - [StickyMinds](http://www.stickyminds.com/sitewide.asp?Function=edetail&ObjectType=ART&ObjectId=9860&tth=DYN&tt=siteemail&iDyn=2) - mentions both PMD and CPD as useful code-checking tools. - -* October 2005 - Levent Gurses' article "Improving Code Quality with PMD and Eclipse" in - [EclipseZone](http://www.eclipsezone.com/articles/pmd/) talks about the PMD Eclipse plugin and explains many - different facets of PMD - XPath, writing rules, the AST, all that. Good stuff! - -* June 2005 - Amit Chaturvedi's article "Java & Static Analysis" in - [Doctor Dobb's Journal](http://www.drdobbs.com/jvm/java-static-analysis/184406143) talks about PMD and shows a - screenshot of the rule designer - -* March 2005 - Kirk Knoernschild's article "Benefits of the Build" in - [Doctor Dobb's Journal](http://www.drdobbs.com/benefits-of-the-build/184415286) mentions PMD as a way - to automate code reviews - -* February 2005 - [Java Is Well-Suited for Open-Source Projects](http://www.eweek.com/c/a/Application-Development/Java-Is-WellSuited-for-OpenSource-Projects/) - - Peter Coffee's eWeek article on open source, Java, and PMD - -* January 2005 - [Zap bugs with PMD](http://www.ibm.com/developerworks/java/library/j-pmd/) - Elliotte Rusty - Harold's article on installing, configuring, and running PMD - -* November 2004 - [PMD: A code analyzer for Java programmers](http://archive09.linux.com/feature/40235) - Daniel - Rubio's article about PMD; includes some notes on XPath rules - -* June 2004 - [Code Improvement Through Cyclomatic Complexity](http://onjava.com/pub/a/onjava/2004/06/16/ccunittest.html) - - Andrew Glover's CCM article featuring PMD - -* June 2004 - [Open Source-Perlen](http://tinyurl.com/3dgpe) - A German article on PMD in Java Magazin - -* June 2004 - [Improving Project Quality with PMD](http://jnb.ociweb.com/jnb/jnbJun2004.html) - Tom Wheeler's - "Java News Brief", June 2004 issue - -* February 2004 - [Software Development](http://www.drdobbs.com/free-as-in-freedom/184415103) - Listed as one of - their 'Open-Source Projects to Watch' - -* November 2003 - [JavaWorld: "Bug patrol"](http://www.javaworld.com/javaworld/jw-11-2003/jw-1121-quality.html) - - Various code inspection tools - -* [JJGuidelines - Java and J2EE Conventions, Guidelines and Best Practices [link broken]](https://jjguidelines.dev.java.net/index.html) - - a project sponsored by the Belgian government to codify coding practices; uses PMD as the compliance checking utility - -* June 2003 - [Software Development Times [link broken]](http://www.sdtimes.com/news/080/story15.htm) - PMD - is embedded in QStudio. - -* May 2003 - [techrepublic.com](http://www.techrepublic.com/article/three-tools-that-make-java-code-review-painless-and-effective/5031836) - - PMD, Checkstyle, and Jalopy - -* April 2003 - [O'Reilly OnJava.com](http://onjava.com/pub/a/onjava/2003/04/09/pmd_rules.html) - PMD custom rules - -* March 2003 - [O'Reilly OnJava.com](http://onjava.com/pub/a/onjava/2003/03/12/pmd_cpd.html) - overview of CPD - -* February 2003 - [O'Reilly OnJava.com](http://onjava.com/pub/a/onjava/2003/02/12/static_analysis.html) - overview of PMD - -* January 2003 - [Sprout](http://netbeans.org/community/articles/interviews/tom_copeland_ole-martin_fr.html) - - interview with Ole-Martin and Tom diff --git a/src/site/markdown/overview/products.md b/src/site/markdown/overview/products.md deleted file mode 100644 index 5e5425d6c3..0000000000 --- a/src/site/markdown/overview/products.md +++ /dev/null @@ -1,56 +0,0 @@ - - -# Products/books related to PMD - -## Open source products - -* Glean - Aggregates PMD + numerous other source code feedback tools - -* QALab - Aggregates PMD + Checkstyle + FindBugs and tracks problems over time - -* XRadar - Using PMD, CPD, and lots of other projects to give measurements on - standard software metrics such as package metrics and dependencies, code size and complexity, code duplications, - coding violations and code-style violations. - -## Commercial products - -* Vanward Technology's Convergence [link broken] - - a quality management dashboard for the Java platform. Thanks to Vanward Technologies for their support of PMD - by buying copies of PMD Applied! - -* Compuware's OptimalAdvisor [link broken] - OptimalAdvisor from ComponentSource - - static code analysis and refactoring tool - -## Books that mention PMD - -* PMD Applied - the official manual; get an extra copy for the home! - Or office! Whatever! - -* Checking Java Programs - by Ian Darwin; - also discusses FindBugs. - -* Sustainable Software Development: An Agile Perspective - - by Kevin Tate, discusses both PMD and CPD - -* High-Assurance Design: Architecting Secure and Reliable Enterprise Applications - - by Cliff Berg, mentions PMD in a discussion of static analysis utilities - -* Eclipse Distilled - by David Carlson, - discusses the PMD plugin - -* Maven: A Developer's Notebook, co-authored by - Vincent Massol, who's done a bunch of work on PMD. Thanks Vincent! - -* Network Security Tools, chapter 6 discusses using PMD - to catch web app security problems. Thanks to Joseph Hemler for the props! - -* Extreme Programming With Ant - -## Articles - -* An introduction - to PMD (in French) - diff --git a/src/site/markdown/overview/similar-projects.md b/src/site/markdown/overview/similar-projects.md deleted file mode 100644 index dccb9a9b4f..0000000000 --- a/src/site/markdown/overview/similar-projects.md +++ /dev/null @@ -1,73 +0,0 @@ - - -# Similar Projects - -## Similar to PMD - -### Open Source - -* Checkstyle - Very detailed, supports both Maven and Ant. - Uses ANTLR. -* DoctorJ - Uses JavaCC. Checks Javadoc, syntax and calculates metrics. -* ESC/Java - - Finds null dereference errors, array bounds errors, type cast errors, and race conditions. - Uses Java Modeling Language annotations. -* FindBugs - works on bytecode, uses BCEL. Source code uses - templates, nifty stuff! -* Hammurapi - - Uses ANTLR, excellent documentation, lots of rules -* Jamit - bytecode analyzer, nice graphs -* JCSC - Does a variety of coding standard checks, uses JavaCC and - the GNU Regexp package. -* Jikes - More than a compiler; now it reports code warnings too -* JLint - Written in C++. Uses data flow analysis and a lock graph to - do lots of synchronization checks. Operates on class files, not source code. -* JPathFinder - A verification VM written by NASA; - supports a subset of the Java packages -* JWiz - Research project, checks some neat stuff, like if - you create a Button without adding an ActionListener to it. Neat. - -### Commercial - -* AppPerfect - 750 rules, - produces PDF/Excel reports, supports auto-fixing problems -* Assent - - The usual stuff, seems pretty complete. -* Aubjex - - Rules aren't listed online. Appears to have some code modification stuff, which would be cool to have in PMD. $299. -* AzoJavaChecker - Rules aren't listed online so it's - hard to tell what they have. Not sure how much it costs since I don't know German. -* CodePro AnalytiX - - Eclipse plug-in, extensive audit rules, JUnit test generation/editing, code coverage and analysis -* Enerjy Java Code Analyser - 200 rules, - lots of IDE plugins -* Flaw Detector - In beta, does control/data flow analysis - to detect NullPointerExceptions -* JStyle - $995, nice folks, lots of metrics and rules -* JTest - Very nice with tons of features, - but also very expensive and requires a running X server (or Xvfb) to run on - Linux. They charge $500 to move a license from one machine to another. -* Lint4J - Lock graph, DFA, and type analysis, many EJB checks -* SolidSDD - Code - duplication detection, nice graphical reporting. Free licensing available for Educational or OSS use. - - -## Similar to CPD - -### Commercial - -* Simian - fast, works with Java, C#, C, CPP, COBOL, JSP, HTML -* Simscan - free for open source projects - -## High level reporting - -* XRadar - Agregates data from a lot of code quality tool to generate - a full quality dashboard. -* Sonar - Pretty much like XRadar, but younger project, fully integrated - to maven 2 (but requires a database) -* Maven Dashboard - Same kind of agregator but - only for maven project. -* QALab - Yet another maven plugin... diff --git a/src/site/markdown/usage/ant-task.md b/src/site/markdown/usage/ant-task.md deleted file mode 100644 index 27bb0d4ef6..0000000000 --- a/src/site/markdown/usage/ant-task.md +++ /dev/null @@ -1,324 +0,0 @@ - - -# Ant Task Usage - -## PMD - -### Description - -Runs a set of static code analysis rules on some source code files and generates a list of problems found. - -### Parameters - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
rulesetfiles - A comma delimited list of ruleset files ('rulesets/java/basic.xml,rulesets/java/design.xml'). - If you write your own ruleset files, you can put them on the classpath and plug them in here. - Yes, unless the ruleset nested element is used
failonerrorWhether or not to fail the build if any errors occur while processing the filesNo
failOnRuleViolationWhether or not to fail the build if PMD finds any problemsNo
minimumPriorityThe rule priority threshold; rules with lower priority than they will not be usedNo
shortFilenamesPlaces truncated filenames in the report. This can reduce your report file size by 15%-20%.No
failuresPropertyNameA property name to plug the number of rule violations into when the task finishesNo
encodingThe character set encoding (e.g. UTF-8) to use when reading the source code filesNo
suppressMarkerThe series of characters to use to tell PMD to skip lines - the default is NOPMD.No
maxRuleViolations - Whether or not to fail the build if PMD finds more than the value of this attribute. - Note that setting this attribute does not require to set the failOnRuleViolation to true. - No
cacheLocation - The location of the analysis cache file to be used. - The cache can greatly improve analysis time without loosing analysis quality. - It's use is strongly recommended. - No
- - -`formatter` nested element - specifies the format of and the files to which the report is written. - - - - - - - - - - - - - - - - - - - - - - -
NameValues
typexml,ideaj,textcolor,text,textpad,emacs,csv,html,xslt,yahtml,summaryhtml,vbhtml,codeclimate
showSuppressedWhether to show suppressed warnings; "false" is the default.
toFileA filename to which to write the report
toConsoleWhether to output the report to the console; "false" is the default.
-

The formatter element can contain nested param elements to configure the formatter in detail, e.g.

-
-
encoding
-
Specifies the encoding to be used in the generated report (only honored when used with `toFile`). When rendering `toConsole` PMD will automatically detect the terminal's encoding and use it, unless the output is being redirected / piped, in which case `file.encoding` is used. See example below.
-
linkPrefix
-
Used for linking to online HTMLized source (like this). See example below.
-
linePrefix
-
Used for linking to online HTMLized source (like this). See example below.
-
-
- - -`classpath` nested element - useful for specifying custom rule. More details on the `classpath` -element are in the Ant documentation [here](http://ant.apache.org/manual/using.html#path) and there's -an example below. - -`auxclasspath` nested element - extra classpath used for Type Resolution rules. - -`sourceLanguage` nested element - specify which language (Java, Ecmascript, XML,...) -and the associated version (1.5, 1.6,...) - -`ruleset` nested element - another way to specify rulesets. Here's an example: - - - - - - rulesets/java/design.xml - java-basic - - - - - - - - - -### Language version selection - -The specific version of a language to be used for parsing is selected via the `sourceLanguage` -nested element. Possible values are: - - - - - - - - - - - - - - - - - - -### Postprocessing the report file with XSLT - -Several folks (most recently, Wouter Zelle) have written XSLT scripts -which you can use to transform the XML report into nifty HTML. To do this, -make sure you use the XML formatter in the PMD task invocation, i.e.: - - - - - -Then, after the end of the PMD task, do this: - - - -### Examples - -Running one ruleset to produce a HTML report (and printing the report to the console as well) using a file cache - - - - - - - - - - - - - -Running multiple rulesets to produce an XML report with the same analysis cache - - - - - - - - - - - - - -Using a custom renderer - - - - - - - - - - - - -Using a classpath reference in the taskdef - - - - - - - - - - - - - - - - - - - -Getting verbose output - - [tom@hal bin]$ ant -v pmd - Apache Ant version 1.6.2 compiled on July 16 2004 - Buildfile: build.xml - Detected Java version: 1.4 in: /usr/local/j2sdk1.4.2_03/jre - Detected OS: Linux - parsing buildfile build.xml with URI = file:/home/tom/data/pmd/pmd/bin/build.xml - Project base dir set to: /home/tom/data/pmd/pmd - Build sequence for target `pmd' is [pmd] - Complete build sequence is [pmd, copy, cppjavacc, cpd, delete, - compile, clean, jar, dist, cpdjnlp, jjtree, javadoc, test, tomserver] - - pmd: - [pmd] Using the normal ClassLoader - [pmd] Using these rulesets: rulesets/java/imports.xml - [pmd] Using rule DontImportJavaLang - [pmd] Using rule UnusedImports - [pmd] Using rule ImportFromSamePackage - [pmd] Using rule DuplicateImports - [pmd] Processing file /usr/local/java/src/java/lang/ref/Finalizer.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/FinalReference.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/PhantomReference.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/Reference.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/ReferenceQueue.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/SoftReference.java - [pmd] Processing file /usr/local/java/src/java/lang/ref/WeakReference.java - [pmd] 0 problems found - - BUILD SUCCESSFUL - Total time: 2 seconds - [tom@hal bin]$ - -An HTML report with the "linkPrefix" gizmo - - - - - - - - - - - - - -An HTML report with the "linePrefix" gizmo - - - - - - - - - - - - - -### Memory Usage - -Memory usage has been reduced significantly starting with the PMD 4.0 release. -When testing all Java rules on the jdk 1.6 source code (about 7000 classes), -the allocated heap space does not go over 60M. - -However, on very large projects, the Ant task may still fail with a OutOfMemoryError. -To prevent this from happening, increase the maximum memory usable by ant using the ANT_OPTS variable -(adjust the size according to your available memory): - -On Windows: - - set ANT_OPTS=-Xmx1024m -Xms512m - -On Linux - - export ANT_OPTS="-Xmx1024m -Xms512m" diff --git a/src/site/markdown/usage/ci-plugins.md b/src/site/markdown/usage/ci-plugins.md deleted file mode 100644 index 2b57b33416..0000000000 --- a/src/site/markdown/usage/ci-plugins.md +++ /dev/null @@ -1,25 +0,0 @@ - - -# Continuous Integrations plugins - -## Introduction - -PMD can be integrate through some of the Continuous Integration tools that exist now. -Here is a list of known (to us) plugin to do so. - -## Hudson Plugin - -Hafner Ullrich has developed a [PMD plugin][hudsonplugin] for Hudson. -Please check the plugin homepage for more info. - -[hudsonplugin]: http://hudson.gotdns.com/wiki/display/HUDSON/PMD+Plugin - -## Continuum - -Continous does not have a plugin for PMD per see, but can failed the build according to the -result of the PMD maven plugin. - - - diff --git a/src/site/markdown/usage/cpd-usage.md b/src/site/markdown/usage/cpd-usage.md deleted file mode 100644 index dd7b23bfc4..0000000000 --- a/src/site/markdown/usage/cpd-usage.md +++ /dev/null @@ -1,492 +0,0 @@ - - -# Finding duplicated code - -Or how to find copied and pasted code - -* [Overview](#Overview) -* [Command line usage](#Command_line_usage) -* [Ant task](#Ant_task) -* [GUI](#GUI) -* [Suppression](#Suppression) - - -## Overview - -Duplicate code can be hard to find, especially in a large project. -But PMD's Copy/Paste Detector (CPD) can find it for you! -CPD has been through three major incarnations: - -* First we wrote it using a variant of Michael Wise's Greedy String Tiling algorithm (our variant is described - [here](http://www.onjava.com/pub/a/onjava/2003/03/12/pmd_cpd.html)). - -* Then it was completely rewritten by Brian Ewins using the - [Burrows-Wheeler transform](http://dogma.net/markn/articles/bwt/bwt.htm). - -* Finally, it was rewritten by Steve Hawkins to use the - [Karp-Rabin](http://www.nist.gov/dads/HTML/karpRabin.html) string matching algorithm. - -Each rewrite made it much faster, and now it can process the JDK 1.4 java.* packages in about 4 seconds -(on my workstation, at least). - -Note that CPD works with Java, JSP, C, C++, C#, Fortran and PHP code and some more languages. For the -full list, see below [Supported Languages](#Supported_Languages). - -Your own language is missing? -See how to add it [here](../customizing/cpd-parser-howto.html). - -CPD is included with PMD, which you can download [here](http://sourceforge.net/projects/pmd/files/pmd/). -Or, if you have [Java Web Start](http://java.sun.com/products/javawebstart/), -you can [run CPD by clicking here](http://pmd.sourceforge.net/cpd.jnlp). - -[Here](./cpdresults.txt) are the duplicates CPD found in the JDK 1.4 source code. - -[Here](./cpp_cpdresults.txt) are the duplicates CPD found in the APACHE_2_0_BRANCH branch of Apache -(just the `httpd-2.0/server/` directory). - - -## Command line usage - -### Windows - -CPD comes with its own starter batch file: `cpd.bat`. It's located in the `bin` subdirectory in the PMD -binary distribution zip-file. Let's assume, you are in this directory, then you can start CPD this way: - - cpd.bat --minimum-tokens 100 --files c:\temp\src\java - -The options "minimum-tokens" and "files" are the two required options; there are more options, see below. - - -### Linux - -For Linux, there is since PMD 5.0 a combined start script for all command line tools. This includes CPD. -The start script is called `run.sh` and is located in the `bin` subdirectory in the PMD binary distribution -zip-file. Let's assume, you are in this directory, then you can start CPD this way: - - ./run.sh cpd --minimum-tokens 100 --files /tmp/src/java - -The options "minimum-tokens" and "files" are the two required options; there are more options, see below. - -### Options - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionDescriptionRequiredApplies for language
--minimum-tokensThe minimum token length which should be reported as a duplicate.yes
--filesList of files and directories to processyes
--filelistPath to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `--files`.no
--languageSources code language. Default value is `java`no
--encodingCharacter encoding to use when processing filesno
--skip-duplicate-filesIgnore multiple copies of files of the same name and length in comparison.no
--excludeFiles to be excluded from CPD checkno
--non-recursiveDon't scan subdirectioriesno
--skip-lexical-errorsSkip files which can't be tokenized due to invalid characters instead of aborting CPDno
--formatReport format. Default value is `text`.no
--failOnViolation {true|false}By default CPD exits with status 4 if code duplications are found. - Disable this option with '--failOnViolation false' to exit with 0 instead and just write the report.no
--ignore-literalsIgnore number values and string contents when comparing textnojava
--ignore-identifiersIgnore constant and variable names when comparing textnojava
--ignore-annotationsIgnore language annotations when comparing textnojava
--ignore-usingsIgnore using directives in C# when comparing textnoC#
--no-skip-blocksDo not skip code blocks marked with --skip-blocks-pattern (e.g. #if 0 until #endif)nocpp
--skip-blocks-pattern - Pattern to find the blocks to skip. Start and End pattern separated by |. - Default is `#if 0|#endif`. - nocpp
--uriURI to processnoplsql
--help / -hPrint help textno
- -### Examples - -_Note:_ The following example use the Linux start script. For Windows, just replace "./run.sh cpd" by "cpd.bat". - - -Minimum required options: Just give it the minimum duplicate size and the source directory: - - $ ./run.sh cpd --minimum-tokens 100 --files /usr/local/java/src/java - -You can also specify the language: - - $ ./run.sh cpd --minimum-tokens 100 --files /path/to/c/source --language cpp - -You may wish to check sources that are stored in different directories: - - $ ./run.sh cpd --minimum-tokens 100 --files /path/to/other/source --files /path/to/other/source --files /path/to/other/source --language fortran - -There should be no limit to the number of '--files', you may add... But if you stumble one, please tell us ! - -And if you're checking a C source tree with duplicate files in different architecture directories -you can skip those using --skip-duplicate-files: - - $ ./run.sh cpd --minimum-tokens 100 --files /path/to/c/source --language cpp --skip-duplicate-files - -You can also specify the encoding to use when parsing files: - - $ ./run.sh cpd --minimum-tokens 100 --files /usr/local/java/src/java --encoding utf-16le - -You can also specify a report format - here we're using the XML report: - - $ ./run.sh cpd --minimum-tokens 100 --files /usr/local/java/src/java --format xml - -The default format is a text report, and there's also a `csv` report. - -Note that CPD is pretty memory-hungry; you may need to give Java more memory to run it, like this: - - $ export HEAPSIZE=512m - $ ./run.sh cpd --minimum-tokens 100 --files /usr/local/java/src/java - -In order to change the heap size under Windows, you'll need to edit the batch file `cpd.bat` set the "OPTS" -variable to `-Xmx512m`. - - -If you specify a source directory but don't want to scan the sub-directories, you can use the non-recursive option: - - $ ./run.sh cpd --minimum-tokens 100 --non-recursive --files /usr/local/java/src/java - -### Exit status - -Please note that if CPD detects duplicated source code, it will exit with status 4 (since 5.0). -This behavior has been introduced to ease CPD integration into scripts or hooks, such as SVN hooks. - - - - - -
0Everything is fine, now code duplications found
1Couldn't understand command line parameters or CPD exited with an exception
4At least one code duplication has been detected unless '--failOnViolation false' is used.
- - -### Supported Languages - -* cs -* cpp -* ecmascript (JavaScript) -* fortran -* go -* java -* jsp -* matlab -* objectivec -* php -* plsql -* python -* ruby -* scala -* swift - - -### Available formats - -* text : Default format -* xml -* csv -* csv_with_linecount_per_file -* vs - - -## Ant task - -Andy Glover wrote an Ant task for CPD; here's how to use it: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionApplies for languageRequired
encoding - The character set encoding (e.g., UTF-8) to use when reading the source code files, but also when - producing the report. A piece of warning, even if you set properly the encoding value, - let's say to UTF-8, but you are running CPD encoded with CP1252, you may end up with not UTF-8 file. - Indeed, CPD copy piece of source code in its report directly, therefore, the source files - keep their encoding.
- If not specified, CPD uses the system default encoding. -
No
formatThe format of the report (e.g. `csv`, `text`, `xml`); defaults to `text`.No
ignoreLiterals - if `true`, CPD ignores literal - value differences when evaluating a duplicate block. This means that `foo=42;` and `foo=43;` - will be seen as equivalent. You may want to run PMD with this option off to start with and - then switch it on to see what it turns up; defaults to `false`. - javaNo
ignoreIdentifiers - Similar to `ignoreLiterals` but for identifiers; i.e., variable names, methods names, - and so forth; defaults to `false`. - javaNo
ignoreAnnotations - Ignore annotations. More and more modern frameworks use annotations on classes and methods, - which can be very redundant and trigger CPD matches. With J2EE (CDI, Transaction Handling, etc) - and Spring (everything) annotations become very redundant. Often classes or methods have the - same 5-6 lines of annotations. This causes false positives; defaults to `false`. - javaNo
ignoreUsings - Ignore using directives in C#. - C#No
skipDuplicateFiles - Ignore multiple copies of files of the same name and length in comparison; defaults to `false`. - No
skipLexicalErrors - Skip files which can't be tokenized due to invalid characters instead of aborting CPD; defaults to `false`. - No
skipBlocks - Enables or disabled skipping of blocks like a pre-processor; defaults to `true`. - See also option skipBlocksPattern. - cppNo
skipBlocksPattern - Configures the pattern, to find the blocks to skip. It is a string property and contains of two parts, - separated by `|`. The first part is the start pattern, the second part is the ending pattern. - The default value is `#if 0|#endif`. - cppno
language - Flag to select the appropriate language (e.g. `c`, `cpp`, `cs`, `java`, `jsp`, `php`, `ruby`, `fortran` - `ecmascript`, and `plsql`); defaults to `java`. - No
minimumtokencountA positive integer indicating the minimum duplicate size.Yes
outputfileThe destination file for the report. If not specified the console will be used instead.No
- -Also, you can get verbose output from this task by running ant with the `-v` flag; i.e.: - - ant -v -f mybuildfile.xml cpd - -Also, you can get an HTML report from CPD by using the XSLT script in pmd/etc/xslt/cpdhtml.xslt. Just run -the CPD task as usual and right after it invoke the Ant XSLT script like this: - - - -## GUI - -CPD also comes with a simple GUI. You can start it via some scripts in the `bin` folder: - -For Windows: - - cpdgui.bat - -For Linux: - - ./run.sh cpdgui - -Here's a [screenshot](../images/screenshot_cpd.png) of CPD after running on the JDK 8 java.lang package: - -![CPD Screenshot after running on the JDK 8 java.lang package](../images/screenshot_cpd.png) - - -## Suppression - -Arbitrary blocks of code can be ignored through comments on **Java** by including the keywords `CPD-OFF` and `CPD-ON`. - - public Object someParameterizedFactoryMethod(int x) throws Exception { - // some unignored code - - // tell cpd to start ignoring code - CPD-OFF - - // mission critical code, manually loop unroll - goDoSomethingAwesome(x + x / 2); - goDoSomethingAwesome(x + x / 2); - goDoSomethingAwesome(x + x / 2); - goDoSomethingAwesome(x + x / 2); - goDoSomethingAwesome(x + x / 2); - goDoSomethingAwesome(x + x / 2); - - // resume CPD analysis - CPD-ON - - // further code will *not* be ignored - } - - -Additionally, **Java** allows to toggle suppression by adding the annotations -**`@SuppressWarnings("CPD-START")`** and **`@SuppressWarnings("CPD-END")`** -all code within will be ignored by CPD. - -This approach however, is limited to the locations were `@SuppressWarnings` is accepted. -It's legacy and the new comment's based approch should be favored. - - //enable suppression - @SuppressWarnings("CPD-START") - public Object someParameterizedFactoryMethod(int x) throws Exception { - // any code here will be ignored for the duplication detection - } - //disable suppression - @SuppressWarnings("CPD-END) - public void nextMethod() { - } - - -Other languages currently have no support to suppress CPD reports. In the future, -the comment based approach will be extended to those of them that can support it. diff --git a/src/site/markdown/usage/installing.md.vm b/src/site/markdown/usage/installing.md.vm deleted file mode 100644 index 1b2612d70b..0000000000 --- a/src/site/markdown/usage/installing.md.vm +++ /dev/null @@ -1,43 +0,0 @@ - - -How to install PMD and CPD -========================== - -Windows -------- - -Requirements: - -* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher -* [Winzip](http://winzip.com) or the free [7-zip](http://www.7-zip.org/) - -Download the latest binary distribution from [the download page](https://sourceforge.net/projects/pmd/files/pmd/) - - i.e., [pmd-bin-${project.version}.zip](https://sourceforge.net/projects/pmd/files/pmd/${project.version}/pmd-bin-${project.version}.zip). - -Unzip it into any directory, i.e., c:\pmd\ - -Linux / Unix ------------- - -Requirements: - -* [Java JRE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 1.7 or higher -* The Unix "zip" utility [InfoZip](http://www.info-zip.org/pub/infozip/) - -Download the latest binary distribution from [the download page](https://sourceforge.net/projects/pmd/files/pmd/) - - i.e., [pmd-bin-${project.version}.zip](https://sourceforge.net/projects/pmd/files/pmd/${project.version}/pmd-bin-${project.version}.zip). - -Unzip it into any directory: - - [tom@hal tmp]$ unzip -q pmd-bin-${project.version}.zip - [tom@hal tmp]$ ls -l - total 4640 - drwxrwxr-x 5 tom tom 4096 Apr 17 16:38 pmd-bin-${project.version} - -rw-rw-r-- 1 tom tom 4733312 Jun 9 15:44 pmd-bin-${project.version}.zip - [tom@hal tmp]$ - - -Note that the PMD binary distribution file contains both [PMD](running.html) and [CPD](cpd-usage.html). diff --git a/src/site/markdown/usage/integrations.md.vm b/src/site/markdown/usage/integrations.md.vm deleted file mode 100644 index 8ac24ebe39..0000000000 --- a/src/site/markdown/usage/integrations.md.vm +++ /dev/null @@ -1,500 +0,0 @@ - - -IDE Integrations -================ - -Summary -------- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDEHomepageSource CodeMaintainers
BlueJpmd-bluejTom Copeland
Codacygithub: codacy/codacy-pmdjavaCodacy
CodeGuideN/AAustin Moore
Eclipsegithub: pmd/pmd-eclipsePhilippe Herlin
eclipse-pmdhttp://acanda.github.io/eclipse-pmd/github: acanda/eclipse-pmdPhilip Graf
Emacsgithub: pmd/pmd-emacsNascif Abousalh Neto
Gelgithub: pmd/pmd-misc/pmd-gelAndrei Lumianski
GradleGradle: The PMD Plugingithub: gradle/gradleGradle.org
IntelliJ IDEAgithub: amitdev/PMD-IntellijAmit Dev
IntelliJ IDEA - QAPlughttp://qaplug.com/N/AJakub Sławiński
JBuildergithub: pmd/pmd-misc/pmd-jbuilderTom Copeland
JCreatorN/ABrant Gurganus
JDevelopergithub: pmd/pmd-jdeveloperTorsten Kleiber
JEditjEdit - PMD Pluginsourceforge: jedit/PMDPluginJiger Patel, Dale Anson
MavenN/AN/A
Maven 2N/Aapache.org / maven
NetBeansSQEgithub: sqe-team/sqeN/A
TextPadN/AJeff Epstein
WebLogic Workshop 8.1.xN/AKevin Conaway
Codacygithub: codacy/codacy-pmdjavaCodacy
- - -General comments ----------------- - -A general note - most plugins include the PMD jar files, which has the rulesets -inside it. So even though the rulesets parameter that some plugins -use (i.e., "rulesets/java/unusedcode.xml") looks like a filesystem reference, it's really -being used by a getResourceAsStream() call to load it out of the PMD jar files. - - -BlueJ ------ - -[BlueJ](http://bluej.org/) is a teaching IDE. To install the PMD extension for BlueJ, download -the [PMDExtension jar file](http://sourceforge.net/projects/pmd/files/pmd-bluej/pmd-bluej-1.0/) -and place it in your `bluej/lib/extensions/` directory. - - -Codacy ------- - -Although it is not an IDE, with [Codacy](https://www.codacy.com/) you have PMDJava analysis out-of-the-box, -and it is free for open source projects. - - -Code Guide ----------- - -Here's how to set up PMD with Omnicore's CodeGuide: - -* Download the PMD zip file from [here](http://sourceforge.net/projects/pmd/files/pmd/) -* Unpack the zip file to your local disk. I put it in /Applications/ -* Add the following tool to CodeGuide (Tools->Configure Tools->New): - * Name: PMD - * Kind: Tool for directories - * Executable: /Applications/pmd-bin-${project.version}/bin/run.sh - * Arguments: pmd -d $DIRECTORY_PATH$ -f emacs $USER_ARGUMENTS$ - -Now you can right click on a source directory, select the PMD tool and a dialog box will appear. -Type in the name of a rule set (e.g. unusedcode). PMD is then executed on the directory you -selected with the rule set you specified. Since CodeGuide understands the emacs syntax you can -click on the file name and CodeGuide will jump to that file and line number. - -Note: I set this up on Mac OS X. It should work on other unix variations just the same. -Of course you need to change the "Executable" setting above to where your PMD is installed. -On Windows you need to use the pmd.bat file instead of pmd.sh. - -If you haven't heard of CodeGuide before, [check it out](http://www.omnicore.com/). -It's a great IDE. - - -Eclipse -------- - -To install the PMD plugin for Eclipse: - -* Start Eclipse and open a project -* Select "Help"->"Software Updates"->"Find and Install" -* Click "Next", then click "New remote site" -* Enter "PMD" into the Name field and into the URL field -* Click through the rest of the dialog boxes to install the plugin - -Alternatively, you can download the latest zip file and follow the above procedures -except for using "New local site" and browsing to the downloaded zip file. - -To configure PMD, select "Windows"->"Preferences", then select PMD. - -To run PMD, right-click on a project node and select "PMD"->"Check code with PMD". - -To run the duplicate code detector, right-click on a project node and -select "PMD"->"Find suspect cut and paste". The report will be placed in a "reports" directory -in a file called "cpd-report.txt". - -To find additional help for other features, please read included help by selecting -Help->Help Contents and browse the "How to..." section in the "PMD Plugin Documentation" book. - -After installing an update, if you get an Exception such as -"java.lang.RuntimeException: Couldn't find that class xxxxx", -try deleting the ruleset.xml file in the .metadata/plugins/net.sourceforge.pmd.eclipse directory in your workspace. - -To get Eclipse to not flag the @SuppressWarnings("PMD") annotation, look -under the menu headings Java -> Compiler -> Errors/Warnings -> Annotations -> Unhandled Warning Token. - - -Emacs ------ - -Integration with GNU Emacs is performed through an ELisp package, pmd.el. -It supports two commands, "pmd-current-buffer" and "pmd-current-dir". -The output is captured in a compilation buffer which allows the user to "jump" -directly to the source code position associated with the PMD warnings. - - -Gel ---- - -Here's how to set up the Gel plugin: - -* Download the pmd-gel-[version].zip file -* Close Gel -* Remove any old plugin versions from your gel\plugins directory -* Unzip the new zip file into your gel\plugins directory -* Start Gel -* Go to Tools->Options->Plugin -* Select the PMD plugin and click "Remove" -* Click "Add" and select "net.sourceforge.pmd.gel.PMDPlugin" -* Restart Gel - -That's pretty much it. Now you can open a Java project and click on Plugins->PMD and -a configuration panel will pop up. You can pick which ruleset you want to run and -you can also pick whether you want to run PMD on the current file or on every -source file in your project. - - -IDEA ----- - -You can use an integrated plugin or just use it as an IDEA "External Tool". - -Amit Dev wrote an integrated plugin for IDEA; you can download that -[from the IntelliJ plugins site](http://plugins.jetbrains.com/idea/plugin/1137-pmdplugin). - -Here's how to set it up as an "External Tool": - -* Open IDEA and go to File->Settings -* Click on the "External Tools" icon -* Click on the Add button -* Fill in the blocks - * Name: PMD - * Description: PMD, good for what ails you. - * Menu: Select the "Main menu", "Project views", "Editor menu", and "Search results" checkboxes. - * Program: $JDKPath$\bin\java.exe - * For the next parameter you'll need to plug in the location of your PMD installation - and the rulesets you want to use - * Parameters: - `-cp %CLASSPATH%;c:\pmd\lib\pmd-${project.version}.jar;c:\pmd\lib\asm-3.2.jar;c:\pmd\lib\jaxen-1.1.1.jar net.sourceforge.pmd.PMD "$FilePath$" ideaj unusedcode,imports "$Sourcepath$" $FileClass$.method $FileName$` - -That's pretty much it. Now you can right click on a source directory and select PMD, -it'll run recursively on the source files, and the results should -be displayed in a window and hyperlinked into the correct file and line of code. I usually -right-click on the message window title bar and unselect "autohide" so the window doesn't go -away every time I fix something in the code window. - - -IDEA - QAPlug -------------- - -QAPlug is an Intellij IDEA plugin to manage code quality. It integrates no less than Checkstyle, FindBugs, and PMD. - -The plugin is available at . - -Also available at the JetBrains site, [QAPlug-PMD](http://plugins.jetbrains.com/idea/plugin/4596-qaplug--pmd) -and [QAPlug](http://plugins.jetbrains.com/idea/plugin/4594-qaplug). - - -JBuilder --------- - -To enable this OpenTool in JBuilder: - -* Download the [latest binary release](https://sourceforge.net/projects/pmd/files/pmd-jbuilder/) -* Unzip it into your `jbuilder/lib/ext/` directory -* Restart JBuilder - -What you can do: - -* Check a single file by bringing up the context menu from the file tab and selecting PMDCheck -* Configure the rulesets that the PMD OpenTool will use by selecting Tools->PMD->Configure PMD -* Check all the files in a project by bringing up the context menu for - the project node and selecting PMD Check Project -* Locate duplicate code by right clicking on a package and selection "Check with CPD" - -When running PMD, the results will be displayed in the MessageView under a tab called PMD Results. If you click on a -violation message within this view, you will be taken to the line in the source code where the violation was detected. - -Things still to do: - -* Enable selection of individual rules within a rule set (maybe) -* Optional insertion of @todo comments at the point of a violation -* Possibly provide configurable ability to limit the number of violations per rule per file - - -JCreator --------- - -1. Open Configure > Options -2. Go to the Tools panel -3. Click New > Program -4. Browse for PMD's pmd.bat -5. Put quotations around the path if it has spaces. -6. Set the initial directory to PMD's \bin directory -7. Check capture output -8. Put '"$[PrjDir]" emacs' followed by desired rulesets in the arguments - -To run PMD on a project, just pick pmd from the Tools menu. - - -JDeveloper ----------- - -To install the PMD plugin for JDeveloper: - -* JDeveloper 10.1.2: Download the binary release and unzip it into your jdev/lib/ext directory -* JDeveloper 10.1.3 upwards: Click "Help", click "Check for Updates" - * JDeveloper 10.1.3: - * Press "Add" to add a new update center - * Name: PMD Update Center - * Location: - * Select Update Center: PMD Update Center - * JDeveloper 11 upwards: Select Update Center: Open Source and Partner Extensions - * Press Next and select the actual PMD Plugin and install it -* Restart JDeveloper - -To run the PMD plugin for JDeveloper: - -* Open the Tools-&Preferences menu -* Click on the PMD option -* Select a couple of rules to try -* To run PMD, right click on either a file, folder, package, project or workspace and select PMD via - Toolbar Icon, Context Menu or File Menu -* Any rule violations should show up in a LogWindow tab at the bottom of the screen - - -JEdit ------ - -The way I use the JEdit plugin is: - -* Dock the ErrorList by going to Utilities->Global Options->Docking and - putting ErrorList at the bottom of the screen -* Open the File Browser if it isn't already open -* Double-click on a source directory -* Select Plugins->PMD->Check directory recursively - -Note that you can select individual rules by going to Utilities->Global Options->Plugin Options->PMD. -Also, you can change the plugin to prompt you for a directory to check by going to that same menu and -selecting the "Ask for Directory" checkbox. - - -Maven ------ - -Please see [the Maven plugins web site](http://maven.apache.org/maven-1.x/plugins/pmd/) for more information. - - -Maven 2 -------- - -Please see -[the Maven 2 plugin web site](http://maven.apache.org/plugins/maven-pmd-plugin/index.html) -for more information. -Also, the bug tracker for this plugin is [here](http://jira.codehaus.org/browse/MPMD). - - -NetBeans --------- - -The [SQE](http://kenai.com/projects/sqe/) project includes PMD integration for NetBeans. - - -TextPad -------- - -**Assumptions** - -* The Java Development Kit, version 1.4.2 (versions 1.4 and higher are acceptable) is properly installed - into your machine, and exists in `D:\java\jdk\_142\`. This means that `D:\java\jdk\_142\bin\java.exe` exists. -* PMD version 5.0 exists in `D:\java\pmd-bin-${project.version}\`. - This means that `D:\java\pmd-bin-${project.version}\lib\pmd-${project.version}.jar` (among other jar files - in the same directory) exist. - -**To integrate into TextPad** - -1. In the **Configure** menu, choose **Preferences...**. This opens the Preferences dialog -2. In the left pane of the Preferences dialog, choose the **Tools** branch by clicking on the *word* "Tools". -3. On the far right of the dialog, click on the **Add** button, and then select **Program...** from the drop-down. - This opens the standard Windows Open File dialog. -4. Type `D:\java\jdk_142\bin\java.exe` and click the **Open** button. In the center pane of the Preferences dialog, - an item "Java" has now been added, and is currently selected. -5. Click the word Java, which makes the word editable. Select the entire word, and type "PMD directory". Press Return. -6. Repeat steps three through five, but type "PMD file", instead of "PMD directory". -7. Click **Apply**. -8. Expand the **Tools** branch (if not already) by clicking on the '`+`' directly to its left. -9. In the expanded list, select **PMD directory**. This changes the right side of this dialog to the "tool" form. -10. In the "tool" form, enter these parameters: - * **Parameters:** `-classpath D:\java\pmd-bin-${project.version}\lib\pmd-${project.version}.jar;D:\java\pmd-bin-${project.version}\lib\asm-3.2.jar;D:\java\pmd-bin-${project.version}\lib\jaxen-1.1.1.jar net.sourceforge.pmd.PMD -d $FileDir -f net.sourceforge.pmd.renderers.TextPadRenderer -R E:\directory\my_pmd_ruleset.xml -debug` - * **Initial Folder:** `$FileDir` - * **Save all documents first:** `Checked` - * **Capture output:** `Checked` - * **_All other checkboxes_:** Unchecked - * **Regular expression to match output:** `^\([^(]+\)(\([0-9]+\),` - * **Registers/File:** `1` - * **Registers/Line:** `2` -11. In the expanded list, select **PMD file**. -12. In the "tool" form, enter the same parameters as above, except replace '`$FileDir`' with '`$File`', - in the Parameters textbox. -13. To save your work (truly, given a quirk of TextPad), click on **OK**, which closes the Preferences dialog. - Restart TextPad and re-open the Preferences dialog. -14. Go back to both the "PMD directory" and "PMD file" Tools branches, and replace '`E:\directory\my_pmd_ruleset.xml`' - with the ruleset of your choice. For example, `basic`. -15. Go to the **Keyboard** branch in the left pane (above **Tools**), which changes the right side to - the "keyboard configuration" form. -16. In the **Categories** list box, select **Tools**. -17. In the **Command** list box, select **PMD directory**. -18. Put your cursor into the **Press new shortcut key**, and type your desired key command. - For example `Ctrl+Page Up` -19. Click **Assign**. -20. In the **Command** list box, select **PMD file**. -21. Put your cursor into the **Press new shortcut key**, and type your desired key command. - For example `Ctrl+Page Down` -22. Click **Assign**. -23. Save your work again: Click on **OK**, which closes the Preferences dialog, and then restart TextPad. - - -**To run PMD against a single Java file** - -1. In TextPad, open any Java file. -2. Click `Ctrl+Page Down`. This opens an empty, read-only text document (titled "Command Results"). - When PMD completes its analysis, this document will be populated with a listing of violated rules - (or "Command completed successfully" indicating no violations). -3. Double click any line to go to it. - - -**To run PMD against a directory of Java files** - -1. In TextPad, open *any* file in the *root* directory you wish to analyze. Unfortunately, you'll need to - create a dummy file, if no file exists there. -2. Click `Ctrl+Page Up`. This opens an empty, read-only text document (titled "Command Results"). - When PMD completes its analysis, this document will be populated with a listing of violated rules - (or "Command completed successfully" indicating no violations). -3. Double click any line to go to it. - -Because directory analysis may take a while, you may choose to cancel this operation. Do so by closing -the (blank Command Results) document, and then confirming that, "yes, I do really want to exit the tool". - - -WebLogic Workshop 8.1.x ------------------------ - -Please see [the WebLogic Workshop plugin project home page](http://pmdwlw.sf.net/) for more information. - diff --git a/src/site/markdown/usage/jspsupport.md b/src/site/markdown/usage/jspsupport.md deleted file mode 100644 index 74edd36646..0000000000 --- a/src/site/markdown/usage/jspsupport.md +++ /dev/null @@ -1,51 +0,0 @@ - - -# JSP Support - -## What is currently supported and what is not - -In short, JSP files that are XHTML-compliant, are supported. -Except for files that contain inline DTDs; only references to external -DTD files are supported (having inline DTD will result in a parsing -error). - -The XHTML support means that: - -* opening tags must be accompanied by corresponding *closing tags* - (or they must be empty tags). This means that currently a "<HR>" - tag without corresponding closing tag will result in a parsing error. - -* *attribute values* must be *surrounded by* single or double *quotes*. This means that the following syntax - will result in a parsing error: - - <MyTag myAttr1=true myAttr2=1024/> - -* < and > characters must be *escaped*, or put inside a CDATA section. - - PMD creates a "Abstract Syntax Tree" representation of source code; the rules use such a tree as input. - For JSP files, the following constructs are parsed into nodes of the tree: - - * XML-elements, XML-attributes, XML-comments, doctype-declarations, CDATA - * JSP-directives, JSP-declarations, JSP-comments, JSP-scriptlets, JSP-expressions, - Expression Language expressions, JSF value bindings - * everything else is seen as flat text nodes. - -* Java code (e.g. in JSP-scriptlets) and EL expressions are not parsed or - further broken down. If you want to create rules that check the code - inside EL expressions or JSP scriptlets (a.o.), you currently would - have to do "manual" string manipulation (e.g. using regular expressions). - -## How to use it - -Using the command-line interface, two new options can be used in the arguments string: - -* "-jsp" : this triggers checking JSP files (they are not checked by default) -* "-nojava" : this tells PMD not to check java source files (they are checked by default) - -Using the Ant task, you decide if PMD must check JSP files by choosing -what files are given to the PMD task. If you use a fileset that -contains only ".java" files, JSP files obviously will not be checked. - -If you want to call the PMD API for checking JSP files, you should investigate the javadoc of PMD. diff --git a/src/site/markdown/usage/maven-plugin.md b/src/site/markdown/usage/maven-plugin.md deleted file mode 100644 index 8f36bd455f..0000000000 --- a/src/site/markdown/usage/maven-plugin.md +++ /dev/null @@ -1,49 +0,0 @@ - - -# Maven 1 PMD plugin - -This page is about the maven 1 PMD plugin. The maven 2 PMD plugin page is available -[here](mvn-plugin.html). - -## Running the pmd plugin - -### report - -To include the Maven report in the project reports section add the following line under -the reports element in your project.xml: - - maven-pmd-plugin - -This will add an entry to the 'project reports' section with the PMD report. - -### manual - -To run PMD on a Maven project without adding it as a report, simply run - - maven pmd xdoc - -The PMD plugin writes the report in XML which will then be formatted into more readable HTML. - -## Customization - -### Changing rulesets - -To specify a set of official, built-in rulesets to be used set them in the property -maven.pmd.rulesets. You can include this setting in your project.properties file. - -A clean strategy for customizing which rules to use for a project is to write a ruleset file. -In this file you can define which rules to use, add custom rules, and -customizing which rules to include/exclude from official rulesets. More information on -writing a ruleset can be found [here](../customizing/howtomakearuleset.html). - -Add to the root of your Maven project a pmd.xml file which contains the ruleset mentioned in -the previous paragraph. Add the following property to your project now: - - maven.pmd.rulesetfiles = ${basedir}/pmd.xml - -## Reference - -See the PMD plugin project page here: - diff --git a/src/site/markdown/usage/mvn-plugin.md b/src/site/markdown/usage/mvn-plugin.md deleted file mode 100644 index 4fd72891b7..0000000000 --- a/src/site/markdown/usage/mvn-plugin.md +++ /dev/null @@ -1,91 +0,0 @@ - - -# Maven 2 plugin - -## Running the pmd plugin - -### report - -To include the mvn report in the project reports section add the following lines under -the reports element in your pom.xml: - - - - ... - - - - org.apache.maven.plugins - maven-pmd-plugin - - - - ... - - -This will add an entry to the 'project reports' section with the PMD report. - - -### manual - -To run PMD on a Maven project without adding it as a report, simply run - - mvn pmd:pmd - -The PMD plugin writes the report in XML which will then be formatted into more readable HTML. - -## Customization - -### Changing rulesets - -To specify a ruleset, simply edit the previous configuration: - - - - - - org.apache.maven.plugins - maven-pmd-plugin - - - /rulesets/java/braces.xml - /rulesets/java/naming.xml - d:\rulesets\strings.xml - http://localhost/design.xml - - - - - - -The value of the 'ruleset' value can either be a relative address, an absolute address or even an url. - -A clean strategy for customizing which rules to use for a project is to write a ruleset file. -In this file you can define which rules to use, add custom rules, and -customizing which rules to include/exclude from official rulesets. More information on -writing a ruleset can be found [here](../customizing/howtomakearuleset.html). -Note that if you include other rulesets in your own rulesets, you have to be sure that the plugin -will be able to resolve those other ruleset references. - -### Other configurations - -The Maven 2 PMD plugin allows you to configure CPD, targetJDK, and the use of XRef to link -the report to html source files, and the file encoding: - - - org.apache.maven.plugins - maven-pmd-plugin - - true - ISO-8859-1 - 30 - 1.4 - - - -## Reference - -For more data, please see the well documented PMD plugin project page here: - diff --git a/src/site/markdown/usage/running.md.vm b/src/site/markdown/usage/running.md.vm deleted file mode 100644 index bbcf5e76f0..0000000000 --- a/src/site/markdown/usage/running.md.vm +++ /dev/null @@ -1,314 +0,0 @@ - - -Running PMD via command line -============================ - -On Linux and other UNIX based operating system... -------------------------------------------------- - -PMD comes with several command line utilities. Previously, each of them had its own start up script, but this has been -greatly simplified since PMD 5.0. ... at least for Unix systems. There is now only one script, called "run.sh", inside -the `bin/` directory of PMD distribution. - -The first argument is the name of the utility you want to execute ('pmd', 'designer', ...) and the other arguments are -specific to the utility used. - - $ ./bin/run.sh pmd -d ../../../src/main/java/ -f text -R rulesets/java/basic.xml -version 1.7 -language java - .../src/main/java/net/sourceforge/pmd/RuleSet.java:123 These nested if statements could be combined - .../src/main/java/net/sourceforge/pmd/RuleSet.java:231 Useless parentheses. - .../src/main/java/net/sourceforge/pmd/RuleSet.java:232 Useless parentheses. - .../src/main/java/net/sourceforge/pmd/RuleSet.java:357 These nested if statements could be combined - .../src/main/java/net/sourceforge/pmd/RuleSetWriter.java:66 Avoid empty catch blocks - .../src/main/java/net/sourceforge/pmd/RuleSetWriter.java:269 Useless parentheses. - -Type "./run.sh pmd -d [filename|jar or zip file containing source code|directory] -f [report format] -R [ruleset file]", i.e: - - /home/user/tmp/pmd-bin-${project.version}/pmd/bin>./run.sh pmd -d /home/user/data/pmd/pmd/test-data/Unused1.java -f xml -R rulesets/java/unusedcode.xml - - - - Avoid unused local variables such as 'fr' - - - - /home/user/tmp/pmd-bin-${project.version}/pmd/bin> - - -Basic usage for Windows ------------------------ - -You can find PMD's starter batch file `pmd.bat` in the `bin` subdirectory. - -Type "pmd -d [filename|jar or zip file containing source code|directory] -f [report format] -R [ruleset file]", i.e: - - C:\tmp\pmd-bin-${project.version}\pmd\bin>pmd -d c:\data\pmd\pmd\test-data\Unused1.java -f xml -R rulesets/java/unusedcode.xml - - - - Avoid unused local variables such as 'fr' - - - - C:\tmp\pmd-bin-${project.version}\pmd\bin> - -You can pass a file name, a directory name, or a jar or zip file name containing Java source code to PMD. - -Also, the PMD binary distribution includes the ruleset files -inside the jar file - even though the "rulesets/java/unusedcode.xml" parameter -above looks like a filesystem reference, it's really being used by a getResourceAsStream() call -to load it out of the PMD jar file. - -Options -------- - -The tool comes with a rather extensive help text, simply running with `-help`! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionDescriptionRequiredApplies for language
-rulesets / -RComma separated list of ruleset names to useyes
-dir / -dRoot directory for sourcesyes
-format / -fReport format type. Default format is `text`.no
-auxclasspath - Specifies the classpath for libraries used by the source code. This is used by the type resolution. - Alternatively a `file://` URL to a text file containing path elements on consecutive lines can be - specified. - no
-uri / -uDatabase URI for sources. If this is given, then you don't need to provide `-dir`.noplsql
-filelistPath to file containing a comma delimited list of files to analyze. If this is given, then you don't need to provide `-dir`.no
-debug / -verbose / -D / -VDebug mode. Prints more log output.no
-help / -h / -HDisplay help on usage.no
-encoding / -eSpecifies the character set encoding of the source code files PMD is reading (i.e. UTF-8). Default is `UTF-8`.no
-threads / -tSets the number of threads used by PMD. Default is `1`. Set threads to '0' to disable multi-threading processing.no
-benchmark / -bBenchmark mode - output a benchmark report upon completion; defaults to System.errno
-stress / -SPerforms a stress test.no
-shortnamesPrints shortened filenames in the report.no
-showsuppressedReport should show suppressed rule violations.no
-suppressmarkerSpecifies the string that marks the line which PMD should ignore; default is `NOPMD`.no
-minimumpriority / -minRule priority threshold; rules with lower priority than configured here won't be used. Default is `5` - which is the lowest priority.no
-property / -P`{name}={value}`: Define a property for a report format.no
-reportfile / -rSend report output to a file; default to System.outno
-version / -vSpecify version of a language PMD should use.no
-language / -lSpecify a language PMD should use.no
-failOnViolation {true|false}By default PMD exits with status 4 if violations are found. - Disable this option with '-failOnViolation false' to exit with 0 instead and just write the report. - no
-cacheSpecify a location for the analysis cache file to use. - This can greatly improve analysis performance and is highly recommended.no
- - -Exit Status ------------ - -Please note that if PMD detects any violations, it will exit with status 4 (since 5.3). -This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks. - - - - - -
0Everything is fine, now violations found
1Couldn't understand command line parameters or PMD exited with an exception
4At least one violation has been detected unless '-failOnViolation false' is set.
- - -Supported Languages -------------------- - -* [java](../pmd-java/rules/index.html) -* [ecmascript](../pmd-javascript/rules/index.html) (JavaScript) -* [jsp](../pmd-jsp/rules/index.html) -* [plsql](../pmd-plsql/rules/index.html) -* [vm](../pmd-vm/rules/index.html) (Apache Velocity) -* [xml and xsl](../pmd-xml/rules/index.html) - - -Available Report Formats / Renderers ------------------------------------- - -PMD comes with many different renderer types: - -* **codeclimate**: Renderer for Code Climate JSON format. - -* **csv**: Comma-separated values tabular format. - - Properties: - - * problem: Include problem column. Default: true. - * package: Include package column. Default: true. - * file: Include file column. Default: true. - * priority: Include priority column. Default: true. - * line: Include line column. Default: true. - * desc: Include description column. Default: true. - * ruleSet: Include Rule set column. Default: true. - * rule: Include Rule column. Default: true. - -* **emacs**: GNU Emacs integration. - -* **html**: HTML format. - - Properties: - - * linePrefix: Prefix for line number anchor in the source file. - * linkPrefix: Path to HTML source. - -* **ideaj**: IntelliJ IDEA integration. - - Properties: - - * classAndMethodName: Class and method name, pass '.method' when processing a directory. - * sourcePath: - * fileName: - -* **summaryhtml**: Summary HTML format. - - Properties: - - * linePrefix: Prefix for line number anchor in the source file. - * linkPrefix: Path to HTML source. - -* **text**: Text format. - -* **textcolor**: Text format, with color support (requires ANSI console support, e.g. xterm, rxvt, etc.). - - Properties: - - * color: Enables colors with anything other than 'false' or '0'. Default: yes. - -* **textpad**: TextPad integration. - -* **vbhtml**: Vladimir Bossicard HTML format. - -* **xml**: XML format. - - Properties: - - * encoding: XML encoding format, defaults to UTF-8. - -* **xslt**: XML with a XSL transformation applied. - - Properties: - - * encoding: XML encoding format, defaults to UTF-8. - * xsltFilename: The XSLT file name. - -* **yahtml**: Yet Another HTML format. - - Properties: - - * outputDir: Output directory. diff --git a/src/site/markdown/usage/suppressing.md b/src/site/markdown/usage/suppressing.md deleted file mode 100644 index f495ec2350..0000000000 --- a/src/site/markdown/usage/suppressing.md +++ /dev/null @@ -1,165 +0,0 @@ - - -# Suppressing warnings - -PMD provides several methods by which Rule violations can be suppressed. -Follow these steps to help you determine which expression method works best -for you: - -1. Is the thing you need to suppress universally appealing to other - users of PMD, or is it a false positive? Can you modify the Rule to - support this specific suppression via a configuration property, or to - fix the false positive? If you can do this, then please do so, and - submit a patch back to the PMD project. Since PMD is built by users - for users, your help would be greatly appreciated by everyone. If you - cannot... - -2. Can you use Annotations or the NOPMD marker to work around your - particular issue on a case by case basis? If not... - -3. Can a regular expression matching the violation message work - around your particular issue? If not... - -4. Can a XPath query on the violation node work around your particular - issue? If not... - -5. Your last and final option is to see the first point about - changing the Rule, but you do not need to submit a patch back to the - PMD project. - -If you need to modify the Rule, see [How to write a rule](../customizing/howtowritearule.html). -Otherwise, the other suppression methods are explain in the following sections. - -## Annotations - -You can use a JDK 1.5 annotation to suppress PMD warnings, like this: - - // This will suppress all the PMD warnings in this class - @SuppressWarnings("PMD") - public class Bar { - void bar() { - int foo; - } - } - -Or you can suppress one rule with an annotation like this: - - // This will suppress UnusedLocalVariable warnings in this class - @SuppressWarnings("PMD.UnusedLocalVariable") - public class Bar { - void bar() { - int foo; - } - } - -PMD also obeys the JDK annotation @SuppressWarnings("unused"), which will apply to all rules in the unused ruleset. - - // This will suppress UnusedLocalVariable and UnusedPrivateMethod warnings in this class - @SuppressWarnings("unused") - public class Bar { - void bar() { - int foo; - } - private void foobar(){} - } - - -## NOPMD - -Alternatively, you can tell PMD to ignore a specific line by using the "NOPMD" marker, like this: - - public class Bar { - // 'bar' is accessed by a native method, so we want to suppress warnings for it - private int bar; //NOPMD - } - -You can use whatever text string you want to suppress warnings, for example, here's -how to use TURN\_OFF\_WARNINGS as the suppressor: - - $ cat Foo.java - public class Foo { - void bar() { - int x = 2; // TURN_OFF_WARNINGS - } - } - - $ ./run.sh pmd -d Foo.java -f text -R java-unusedcode -suppressmarker TURN_OFF_WARNINGS - No problems found! - UnusedLocalVariable rule violation suppressed by //NOPMD in /home/tom/pmd/pmd/bin/Foo.java - -Note that PMD expects the //NOPMD marker to be on the same line as the violation. So, for -example, if you want to suppress an "empty if statement" warning, you'll need to place it on -the line containing the "if" keyword, e.g.: - - $ cat ~/tmp/Foo.java - public class Foo { - void bar() { - int x = 42; - if (x > 5) { // NOPMD - } - } - } - $ java net.sourceforge.pmd.PMD -d ~/tmp/Foo.java -f text -R java-basic - No problems found! - $ - -A message placed after the NOPMD marker will get placed in the report, e.g.: - - public class Foo { - void bar() { - try { - bar(); - } catch (FileNotFoundException e) {} // NOPMD - this surely will never happen - } - } - -## Violation Suppress Regex - -If a particular Rule does not provide a property to customize behavior -sufficiently, you can fall back to using the global 'violationSuppressRegex' -property. This property defines a regular expression to match against the -message of the violation. If the regular expression matches, -then the violation will be suppressed. - -When using a Rule reference in a RuleSet XML, you can customize the -Rule by adding the 'violationSuppressRegex' property. For example, to -suppress reporting specifically named parameters which are unused: - - - - - - - - -Note for message based suppression to work, you must know who to write -a regular expression that matches the message of violations you wish to -suppress. Regular expressions are explained in the JavaDoc for standard -Java class java.util.regex.Pattern. - -## Violation Suppress XPath - -If a particular Rule does not provide a property to customize behavior -sufficiently, you can fall back to using the global 'violationSuppressXPath' -property. This property defines an XPath query to be executed using the -violation node as the starting point. If the XPath query matches anything, -then the violation will be suppressed. - -When using a Rule reference in a RuleSet XML, you can customize the -Rule by adding the 'violationSuppressXPath' property. For example, to -suppress reporting specifically typed parameters which are unused: - - - - - - - -Note for XPath based suppression to work, you must know how to write -an XPath query that matches the AST structure of the nodes of the -violations you wish to suppress. XPath queries are explained in -[XPath Rule tutorial](../customizing/xpathruletutorial.html). - -Suggestions? Comments? Post them [here](http://sourceforge.net/p/pmd/discussion/188192). Thanks! diff --git a/src/site/resources/cpdresults.txt b/src/site/resources/cpdresults.txt deleted file mode 100644 index 2c46133adf..0000000000 --- a/src/site/resources/cpdresults.txt +++ /dev/null @@ -1,11305 +0,0 @@ -===================================================================== -Found a 121 line (629 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectCharBufferU.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectCharBufferS.java - DirectCharBufferS sb = (DirectCharBufferS)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public CharBuffer put(char[] src, int offset, int length) { - - if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromCharArray(src, offset << 1, - ix(pos), length << 1); - else - Bits.copyFromByteArray(src, offset << 1, - ix(pos), length << 1); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public CharBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 1); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = (pos + start) << 1; - return new DirectCharBufferS(this, -1, 0, sublen, sublen, off); -===================================================================== -Found a 294 line (531 tokens) duplication in the following files: -Starting at line 486 of /usr/local/java/src/java/lang/StrictMath.java -Starting at line 575 of /usr/local/java/src/java/lang/Math.java - public static int round(float a) { - return (int)floor(a + 0.5f); - } - - /** - * Returns the closest long to the argument. The result - * is rounded to an integer by adding 1/2, taking the floor of the - * result, and casting the result to type long. In other - * words, the result is equal to the value of the expression: - *

(long)Math.floor(a + 0.5d)
- *

- * Special cases: - *

  • If the argument is NaN, the result is 0. - *
  • If the argument is negative infinity or any value less than or - * equal to the value of Long.MIN_VALUE, the result is - * equal to the value of Long.MIN_VALUE. - *
  • If the argument is positive infinity or any value greater than or - * equal to the value of Long.MAX_VALUE, the result is - * equal to the value of Long.MAX_VALUE.
- * - * @param a a floating-point value to be rounded to a - * long. - * @return the value of the argument rounded to the nearest - * long value. - * @see java.lang.Long#MAX_VALUE - * @see java.lang.Long#MIN_VALUE - */ - public static long round(double a) { - return (long)floor(a + 0.5d); - } - - private static Random randomNumberGenerator; - - private static synchronized void initRNG() { - if (randomNumberGenerator == null) - randomNumberGenerator = new Random(); - } - - /** - * Returns a double value with a positive sign, greater - * than or equal to 0.0 and less than 1.0. - * Returned values are chosen pseudorandomly with (approximately) - * uniform distribution from that range. - *

- * When this method is first called, it creates a single new - * pseudorandom-number generator, exactly as if by the expression - *

new java.util.Random
- * This new pseudorandom-number generator is used thereafter for all - * calls to this method and is used nowhere else. - *

- * This method is properly synchronized to allow correct use by more - * than one thread. However, if many threads need to generate - * pseudorandom numbers at a great rate, it may reduce contention for - * each thread to have its own pseudorandom-number generator. - * - * @return a pseudorandom double greater than or equal - * to 0.0 and less than 1.0. - * @see java.util.Random#nextDouble() - */ - public static double random() { - if (randomNumberGenerator == null) initRNG(); - return randomNumberGenerator.nextDouble(); - } - - /** - * Returns the absolute value of an int value. - * If the argument is not negative, the argument is returned. - * If the argument is negative, the negation of the argument is returned. - *

- * Note that if the argument is equal to the value of - * Integer.MIN_VALUE, the most negative representable - * int value, the result is that same value, which is - * negative. - * - * @param a the argument whose absolute value is to be determined - * @return the absolute value of the argument. - * @see java.lang.Integer#MIN_VALUE - */ - public static int abs(int a) { - return (a < 0) ? -a : a; - } - - /** - * Returns the absolute value of a long value. - * If the argument is not negative, the argument is returned. - * If the argument is negative, the negation of the argument is returned. - *

- * Note that if the argument is equal to the value of - * Long.MIN_VALUE, the most negative representable - * long value, the result is that same value, which is - * negative. - * - * @param a the argument whose absolute value is to be determined - * @return the absolute value of the argument. - * @see java.lang.Long#MIN_VALUE - */ - public static long abs(long a) { - return (a < 0) ? -a : a; - } - - /** - * Returns the absolute value of a float value. - * If the argument is not negative, the argument is returned. - * If the argument is negative, the negation of the argument is returned. - * Special cases: - *

  • If the argument is positive zero or negative zero, the - * result is positive zero. - *
  • If the argument is infinite, the result is positive infinity. - *
  • If the argument is NaN, the result is NaN.
- * In other words, the result is the same as the value of the expression: - *

Float.intBitsToFloat(0x7fffffff & Float.floatToIntBits(a))
- * - * @param a the argument whose absolute value is to be determined - * @return the absolute value of the argument. - */ - public static float abs(float a) { - return (a <= 0.0F) ? 0.0F - a : a; - } - - /** - * Returns the absolute value of a double value. - * If the argument is not negative, the argument is returned. - * If the argument is negative, the negation of the argument is returned. - * Special cases: - *
  • If the argument is positive zero or negative zero, the result - * is positive zero. - *
  • If the argument is infinite, the result is positive infinity. - *
  • If the argument is NaN, the result is NaN.
- * In other words, the result is the same as the value of the expression: - *

Double.longBitsToDouble((Double.doubleToLongBits(a)<<1)>>>1) - * - * @param a the argument whose absolute value is to be determined - * @return the absolute value of the argument. - */ - public static double abs(double a) { - return (a <= 0.0D) ? 0.0D - a : a; - } - - /** - * Returns the greater of two int values. That is, the - * result is the argument closer to the value of - * Integer.MAX_VALUE. If the arguments have the same value, - * the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the larger of a and b. - * @see java.lang.Long#MAX_VALUE - */ - public static int max(int a, int b) { - return (a >= b) ? a : b; - } - - /** - * Returns the greater of two long values. That is, the - * result is the argument closer to the value of - * Long.MAX_VALUE. If the arguments have the same value, - * the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the larger of a and b. - * @see java.lang.Long#MAX_VALUE - */ - public static long max(long a, long b) { - return (a >= b) ? a : b; - } - - private static long negativeZeroFloatBits = Float.floatToIntBits(-0.0f); - private static long negativeZeroDoubleBits = Double.doubleToLongBits(-0.0d); - - /** - * Returns the greater of two float values. That is, - * the result is the argument closer to positive infinity. If the - * arguments have the same value, the result is that same - * value. If either value is NaN, then the result is NaN. Unlike - * the the numerical comparison operators, this method considers - * negative zero to be strictly smaller than positive zero. If one - * argument is positive zero and the other negative zero, the - * result is positive zero. - * - * @param a an argument. - * @param b another argument. - * @return the larger of a and b. - */ - public static float max(float a, float b) { - if (a != a) return a; // a is NaN - if ((a == 0.0f) && (b == 0.0f) - && (Float.floatToIntBits(a) == negativeZeroFloatBits)) { - return b; - } - return (a >= b) ? a : b; - } - - /** - * Returns the greater of two double values. That - * is, the result is the argument closer to positive infinity. If - * the arguments have the same value, the result is that same - * value. If either value is NaN, then the result is NaN. Unlike - * the the numerical comparison operators, this method considers - * negative zero to be strictly smaller than positive zero. If one - * argument is positive zero and the other negative zero, the - * result is positive zero. - * - * @param a an argument. - * @param b another argument. - * @return the larger of a and b. - */ - public static double max(double a, double b) { - if (a != a) return a; // a is NaN - if ((a == 0.0d) && (b == 0.0d) - && (Double.doubleToLongBits(a) == negativeZeroDoubleBits)) { - return b; - } - return (a >= b) ? a : b; - } - - /** - * Returns the smaller of two int values. That is, - * the result the argument closer to the value of - * Integer.MIN_VALUE. If the arguments have the same - * value, the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of a and b. - * @see java.lang.Long#MIN_VALUE - */ - public static int min(int a, int b) { - return (a <= b) ? a : b; - } - - /** - * Returns the smaller of two long values. That is, - * the result is the argument closer to the value of - * Long.MIN_VALUE. If the arguments have the same - * value, the result is that same value. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of a and b. - * @see java.lang.Long#MIN_VALUE - */ - public static long min(long a, long b) { - return (a <= b) ? a : b; - } - - /** - * Returns the smaller of two float values. That is, - * the result is the value closer to negative infinity. If the - * arguments have the same value, the result is that same - * value. If either value is NaN, then the result is NaN. Unlike - * the the numerical comparison operators, this method considers - * negative zero to be strictly smaller than positive zero. If - * one argument is positive zero and the other is negative zero, - * the result is negative zero. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of a and b. - */ - public static float min(float a, float b) { - if (a != a) return a; // a is NaN - if ((a == 0.0f) && (b == 0.0f) - && (Float.floatToIntBits(b) == negativeZeroFloatBits)) { - return b; - } - return (a <= b) ? a : b; - } - - /** - * Returns the smaller of two double values. That - * is, the result is the value closer to negative infinity. If the - * arguments have the same value, the result is that same - * value. If either value is NaN, then the result is NaN. Unlike - * the the numerical comparison operators, this method considers - * negative zero to be strictly smaller than positive zero. If one - * argument is positive zero and the other is negative zero, the - * result is negative zero. - * - * @param a an argument. - * @param b another argument. - * @return the smaller of a and b. - */ - public static double min(double a, double b) { - if (a != a) return a; // a is NaN - if ((a == 0.0d) && (b == 0.0d) - && (Double.doubleToLongBits(b) == negativeZeroDoubleBits)) { - return b; - } - return (a <= b) ? a : b; - } - -} -===================================================================== -Found a 27 line (523 tokens) duplication in the following files: -Starting at line 610 of /usr/local/java/src/java/util/BitSet.java -Starting at line 2294 of /usr/local/java/src/java/math/BigInteger.java - final static byte trailingZeroTable[] = { - -25, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; - - /** - * Returns the number of bits in the two's complement representation - * of this BigInteger that differ from its sign bit. This method is - * useful when implementing bit-vector style sets atop BigIntegers. - * - * @return number of bits in the two's complement representation - * of this BigInteger that differ from its sign bit. - */ - public int bitCount() { -===================================================================== -Found a 64 line (506 tokens) duplication in the following files: -Starting at line 2243 of /usr/local/java/src/java/awt/geom/AffineTransform.java -Starting at line 2544 of /usr/local/java/src/java/awt/geom/AffineTransform.java - switch (state) { - default: - stateError(); - /* NOTREACHED */ - case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE): - M00 = m00; M01 = m01; M02 = m02; - M10 = m10; M11 = m11; M12 = m12; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - double y = srcPts[srcOff++]; - dstPts[dstOff++] = (float) (M00 * x + M01 * y + M02); - dstPts[dstOff++] = (float) (M10 * x + M11 * y + M12); - } - return; - case (APPLY_SHEAR | APPLY_SCALE): - M00 = m00; M01 = m01; - M10 = m10; M11 = m11; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - double y = srcPts[srcOff++]; - dstPts[dstOff++] = (float) (M00 * x + M01 * y); - dstPts[dstOff++] = (float) (M10 * x + M11 * y); - } - return; - case (APPLY_SHEAR | APPLY_TRANSLATE): - M01 = m01; M02 = m02; - M10 = m10; M12 = m12; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - dstPts[dstOff++] = (float) (M01 * srcPts[srcOff++] + M02); - dstPts[dstOff++] = (float) (M10 * x + M12); - } - return; - case (APPLY_SHEAR): - M01 = m01; M10 = m10; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - dstPts[dstOff++] = (float) (M01 * srcPts[srcOff++]); - dstPts[dstOff++] = (float) (M10 * x); - } - return; - case (APPLY_SCALE | APPLY_TRANSLATE): - M00 = m00; M02 = m02; - M11 = m11; M12 = m12; - while (--numPts >= 0) { - dstPts[dstOff++] = (float) (M00 * srcPts[srcOff++] + M02); - dstPts[dstOff++] = (float) (M11 * srcPts[srcOff++] + M12); - } - return; - case (APPLY_SCALE): - M00 = m00; M11 = m11; - while (--numPts >= 0) { - dstPts[dstOff++] = (float) (M00 * srcPts[srcOff++]); - dstPts[dstOff++] = (float) (M11 * srcPts[srcOff++]); - } - return; - case (APPLY_TRANSLATE): - M02 = m02; M12 = m12; - while (--numPts >= 0) { - dstPts[dstOff++] = (float) (srcPts[srcOff++] + M02); - dstPts[dstOff++] = (float) (srcPts[srcOff++] + M12); - } - return; - case (APPLY_IDENTITY): -===================================================================== -Found a 136 line (455 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectFloatBufferS.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectFloatBufferU.java - DirectFloatBufferU sb = (DirectFloatBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public FloatBuffer put(float[] src, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromIntArray(src, offset << 2, - ix(pos), length << 2); - else - Bits.copyFromByteArray(src, offset << 2, - ix(pos), length << 2); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public FloatBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 2); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 132 line (455 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectShortBufferU.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectShortBufferS.java - DirectShortBufferS sb = (DirectShortBufferS)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public ShortBuffer put(short[] src, int offset, int length) { - - if ((length << 1) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromShortArray(src, offset << 1, - ix(pos), length << 1); - else - Bits.copyFromByteArray(src, offset << 1, - ix(pos), length << 1); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public ShortBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 1); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 132 line (455 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectLongBufferS.java - DirectLongBufferS sb = (DirectLongBufferS)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public LongBuffer put(long[] src, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromLongArray(src, offset << 3, - ix(pos), length << 3); - else - Bits.copyFromByteArray(src, offset << 3, - ix(pos), length << 3); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 3); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 136 line (455 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectIntBufferU.java - DirectIntBufferU sb = (DirectIntBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public IntBuffer put(int[] src, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromIntArray(src, offset << 2, - ix(pos), length << 2); - else - Bits.copyFromByteArray(src, offset << 2, - ix(pos), length << 2); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public IntBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 2); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 136 line (455 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - DirectDoubleBufferU sb = (DirectDoubleBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public DoubleBuffer put(double[] src, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromLongArray(src, offset << 3, - ix(pos), length << 3); - else - Bits.copyFromByteArray(src, offset << 3, - ix(pos), length << 3); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public DoubleBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 3); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 64 line (436 tokens) duplication in the following files: -Starting at line 2356 of /usr/local/java/src/java/awt/geom/AffineTransform.java -Starting at line 2450 of /usr/local/java/src/java/awt/geom/AffineTransform.java - switch (state) { - default: - stateError(); - /* NOTREACHED */ - case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE): - M00 = m00; M01 = m01; M02 = m02; - M10 = m10; M11 = m11; M12 = m12; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - double y = srcPts[srcOff++]; - dstPts[dstOff++] = M00 * x + M01 * y + M02; - dstPts[dstOff++] = M10 * x + M11 * y + M12; - } - return; - case (APPLY_SHEAR | APPLY_SCALE): - M00 = m00; M01 = m01; - M10 = m10; M11 = m11; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - double y = srcPts[srcOff++]; - dstPts[dstOff++] = M00 * x + M01 * y; - dstPts[dstOff++] = M10 * x + M11 * y; - } - return; - case (APPLY_SHEAR | APPLY_TRANSLATE): - M01 = m01; M02 = m02; - M10 = m10; M12 = m12; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - dstPts[dstOff++] = M01 * srcPts[srcOff++] + M02; - dstPts[dstOff++] = M10 * x + M12; - } - return; - case (APPLY_SHEAR): - M01 = m01; M10 = m10; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - dstPts[dstOff++] = M01 * srcPts[srcOff++]; - dstPts[dstOff++] = M10 * x; - } - return; - case (APPLY_SCALE | APPLY_TRANSLATE): - M00 = m00; M02 = m02; - M11 = m11; M12 = m12; - while (--numPts >= 0) { - dstPts[dstOff++] = M00 * srcPts[srcOff++] + M02; - dstPts[dstOff++] = M11 * srcPts[srcOff++] + M12; - } - return; - case (APPLY_SCALE): - M00 = m00; M11 = m11; - while (--numPts >= 0) { - dstPts[dstOff++] = M00 * srcPts[srcOff++]; - dstPts[dstOff++] = M11 * srcPts[srcOff++]; - } - return; - case (APPLY_TRANSLATE): - M02 = m02; M12 = m12; - while (--numPts >= 0) { - dstPts[dstOff++] = srcPts[srcOff++] + M02; - dstPts[dstOff++] = srcPts[srcOff++] + M12; - } - return; - case (APPLY_IDENTITY): -===================================================================== -Found a 60 line (352 tokens) duplication in the following files: -Starting at line 72 of /usr/local/java/src/java/lang/CharacterData.java -Starting at line 73 of /usr/local/java/src/java/lang/CharacterDataLatin1.java - } - - static boolean isDigit(char ch) { - return getType(ch) == Character.DECIMAL_DIGIT_NUMBER; - } - - static boolean isDefined(char ch) { - return getType(ch) != Character.UNASSIGNED; - } - - static boolean isLetter(char ch) { - return (((((1 << Character.UPPERCASE_LETTER) | - (1 << Character.LOWERCASE_LETTER) | - (1 << Character.TITLECASE_LETTER) | - (1 << Character.MODIFIER_LETTER) | - (1 << Character.OTHER_LETTER)) >> getType(ch)) & 1) != 0); - } - - static boolean isLetterOrDigit(char ch) { - return (((((1 << Character.UPPERCASE_LETTER) | - (1 << Character.LOWERCASE_LETTER) | - (1 << Character.TITLECASE_LETTER) | - (1 << Character.MODIFIER_LETTER) | - (1 << Character.OTHER_LETTER) | - (1 << Character.DECIMAL_DIGIT_NUMBER)) >> getType(ch)) & 1) != 0); - } - - static boolean isSpaceChar(char ch) { - return (((((1 << Character.SPACE_SEPARATOR) | - (1 << Character.LINE_SEPARATOR) | - (1 << Character.PARAGRAPH_SEPARATOR)) - >> getType(ch)) & 1) != 0); - } - - - static boolean isJavaIdentifierStart(char ch) { - return (getProperties(ch) & 0x00007000) >= 0x00005000; - } - - static boolean isJavaIdentifierPart(char ch) { - return (getProperties(ch) & 0x00003000) != 0; - } - - static boolean isUnicodeIdentifierStart(char ch) { - return (getProperties(ch) & 0x00007000) == 0x00007000; - } - - static boolean isUnicodeIdentifierPart(char ch) { - return (getProperties(ch)& 0x00001000) != 0; - } - - static boolean isIdentifierIgnorable(char ch) { - return (getProperties(ch) & 0x00007000) == 0x00001000; - } - - static char toLowerCase(char ch) { - char mapChar = ch; - int val = getProperties(ch); - - if (((val & 0x00020000) != 0) && -===================================================================== -Found a 19 line (329 tokens) duplication in the following files: -Starting at line 685 of /usr/local/java/src/java/util/BitSet.java -Starting at line 2270 of /usr/local/java/src/java/math/BigInteger.java - static int bitLen(int w) { - // Binary search - decision tree (5 tests, rarely 6) - return - (w < 1<<15 ? - (w < 1<<7 ? - (w < 1<<3 ? - (w < 1<<1 ? (w < 1<<0 ? (w<0 ? 32 : 0) : 1) : (w < 1<<2 ? 2 : 3)) : - (w < 1<<5 ? (w < 1<<4 ? 4 : 5) : (w < 1<<6 ? 6 : 7))) : - (w < 1<<11 ? - (w < 1<<9 ? (w < 1<<8 ? 8 : 9) : (w < 1<<10 ? 10 : 11)) : - (w < 1<<13 ? (w < 1<<12 ? 12 : 13) : (w < 1<<14 ? 14 : 15)))) : - (w < 1<<23 ? - (w < 1<<19 ? - (w < 1<<17 ? (w < 1<<16 ? 16 : 17) : (w < 1<<18 ? 18 : 19)) : - (w < 1<<21 ? (w < 1<<20 ? 20 : 21) : (w < 1<<22 ? 22 : 23))) : - (w < 1<<27 ? - (w < 1<<25 ? (w < 1<<24 ? 24 : 25) : (w < 1<<26 ? 26 : 27)) : - (w < 1<<29 ? (w < 1<<28 ? 28 : 29) : (w < 1<<30 ? 30 : 31))))); - } -===================================================================== -Found a 69 line (328 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferB.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferL.java - Bits.putCharL(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public CharBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 1); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); - return new ByteBufferAsCharBufferL(bb, -1, 0, sublen, sublen, off); -===================================================================== -Found a 214 line (326 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectCharBufferRS.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectCharBufferRU.java - return new DirectCharBufferRU(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public CharBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public CharBuffer put(char x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer put(int i, char x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer put(CharBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer put(char[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = (pos + start) << 1; - return new DirectCharBufferRU(this, -1, 0, sublen, sublen, off); -===================================================================== -Found a 87 line (299 tokens) duplication in the following files: -Starting at line 1259 of /usr/local/java/src/java/awt/geom/CubicCurve2D.java -Starting at line 929 of /usr/local/java/src/java/awt/geom/QuadCurve2D.java - vals[j++] = c1*u*u + 2*ctrl*t*u + c2*t*t; - } - } - return j; - } - - private static final int BELOW = -2; - private static final int LOWEDGE = -1; - private static final int INSIDE = 0; - private static final int HIGHEDGE = 1; - private static final int ABOVE = 2; - - /* - * Determine where coord lies with respect to the range from - * low to high. It is assumed that low <= high. The return - * value is one of the 5 values BELOW, LOWEDGE, INSIDE, HIGHEDGE, - * or ABOVE. - */ - private static int getTag(double coord, double low, double high) { - if (coord <= low) { - return (coord < low ? BELOW : LOWEDGE); - } - if (coord >= high) { - return (coord > high ? ABOVE : HIGHEDGE); - } - return INSIDE; - } - - /* - * Determine if the pttag represents a coordinate that is already - * in its test range, or is on the border with either of the two - * opttags representing another coordinate that is "towards the - * inside" of that test range. In other words, are either of the - * two "opt" points "drawing the pt inward"? - */ - private static boolean inwards(int pttag, int opt1tag, int opt2tag) { - switch (pttag) { - case BELOW: - case ABOVE: - default: - return false; - case LOWEDGE: - return (opt1tag >= INSIDE || opt2tag >= INSIDE); - case INSIDE: - return true; - case HIGHEDGE: - return (opt1tag <= INSIDE || opt2tag <= INSIDE); - } - } - - /** - * Tests if the shape of this QuadCurve2D intersects the - * interior of a specified set of rectangular coordinates. - * @param x, y the coordinates of the upper-left corner of the - * specified rectangular area - * @param w the width of the specified rectangular area - * @param h the height of the specified rectangular area - * @return true if the shape of this - * QuadCurve2D intersects the interior of the - * specified set of rectangular coordinates; - * false otherwise. - */ - public boolean intersects(double x, double y, double w, double h) { - // Trivially reject non-existant rectangles - if (w < 0 || h < 0) { - return false; - } - - // Trivially accept if either endpoint is inside the rectangle - // (not on its border since it may end there and not go inside) - // Record where they lie with respect to the rectangle. - // -1 => left, 0 => inside, 1 => right - double x1 = getX1(); - double y1 = getY1(); - int x1tag = getTag(x1, x, x+w); - int y1tag = getTag(y1, y, y+h); - if (x1tag == INSIDE && y1tag == INSIDE) { - return true; - } - double x2 = getX2(); - double y2 = getY2(); - int x2tag = getTag(x2, x, x+w); - int y2tag = getTag(y2, y, y+h); - if (x2tag == INSIDE && y2tag == INSIDE) { - return true; - } - double ctrlx = getCtrlX(); -===================================================================== -Found a 117 line (298 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferRB.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferRL.java - return new ByteBufferAsCharBufferRL(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public CharBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public CharBuffer put(char x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer put(int i, char x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public CharBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); - return new ByteBufferAsCharBufferRL(bb, -1, 0, sublen, sublen, off); -===================================================================== -Found a 40 line (281 tokens) duplication in the following files: -Starting at line 420 of /usr/local/java/src/java/io/FilePermission.java -Starting at line 235 of /usr/local/java/src/java/util/PropertyPermission.java - } - - char[] a = actions.toCharArray(); - - int i = a.length - 1; - if (i < 0) - return mask; - - while (i != -1) { - char c; - - // skip whitespace - while ((i!=-1) && ((c = a[i]) == ' ' || - c == '\r' || - c == '\n' || - c == '\f' || - c == '\t')) - i--; - - // check for the known strings - int matchlen; - - if (i >= 3 && (a[i-3] == 'r' || a[i-3] == 'R') && - (a[i-2] == 'e' || a[i-2] == 'E') && - (a[i-1] == 'a' || a[i-1] == 'A') && - (a[i] == 'd' || a[i] == 'D')) - { - matchlen = 4; - mask |= READ; - - } else if (i >= 4 && (a[i-4] == 'w' || a[i-4] == 'W') && - (a[i-3] == 'r' || a[i-3] == 'R') && - (a[i-2] == 'i' || a[i-2] == 'I') && - (a[i-1] == 't' || a[i-1] == 'T') && - (a[i] == 'e' || a[i] == 'E')) - { - matchlen = 5; - mask |= WRITE; - - } else { -===================================================================== -Found a 156 line (272 tokens) duplication in the following files: -Starting at line 939 of /usr/local/java/src/java/net/Socket.java -Starting at line 800 of /usr/local/java/src/java/net/DatagramSocket.java - Object o = getImpl().getOption(SocketOptions.SO_TIMEOUT); - /* extra type safety */ - if (o instanceof Integer) { - return ((Integer) o).intValue(); - } else { - return 0; - } - } - - /** - * Sets the SO_SNDBUF option to the specified value for this - * DatagramSocket. The SO_SNDBUF option is used by the - * network implementation as a hint to size the underlying - * network I/O buffers. The SO_SNDBUF setting may also be used - * by the network implementation to determine the maximum size - * of the packet that can be sent on this socket. - *

- * As SO_SNDBUF is a hint, applications that want to verify - * what size the buffer is should call {@link #getSendBufferSize()}. - *

- * Increasing the buffer size may allow multiple outgoing packets - * to be queued by the network implementation when the send rate - * is high. - *

- * Note: If {@link #send()} is used to send a - * DatagramPacket that is larger than the setting - * of SO_SNDBUF then it is implementation specific if the - * packet is sent or discarded. - * - * @param size the size to which to set the send buffer - * size. This value must be greater than 0. - * - * @exception SocketException if there is an error - * in the underlying protocol, such as an UDP error. - * @exception IllegalArgumentException if the value is 0 or is - * negative. - * @see #getSendBufferSize() - */ - public synchronized void setSendBufferSize(int size) - throws SocketException{ - if (!(size > 0)) { - throw new IllegalArgumentException("negative send size"); - } - if (isClosed()) - throw new SocketException("Socket is closed"); - getImpl().setOption(SocketOptions.SO_SNDBUF, new Integer(size)); - } - - /** - * Get value of the SO_SNDBUF option for this DatagramSocket, that is the - * buffer size used by the platform for output on this DatagramSocket. - * - * @return the value of the SO_SNDBUF option for this DatagramSocket - * @exception SocketException if there is an error in - * the underlying protocol, such as an UDP error. - * @see #setSendBufferSize - */ - public synchronized int getSendBufferSize() throws SocketException { - if (isClosed()) - throw new SocketException("Socket is closed"); - int result = 0; - Object o = getImpl().getOption(SocketOptions.SO_SNDBUF); - if (o instanceof Integer) { - result = ((Integer)o).intValue(); - } - return result; - } - - /** - * Sets the SO_RCVBUF option to the specified value for this - * DatagramSocket. The SO_RCVBUF option is used by the - * the network implementation as a hint to size the underlying - * network I/O buffers. The SO_RCVBUF setting may also be used - * by the network implementation to determine the maximum size - * of the packet that can be received on this socket. - *

- * Because SO_RCVBUF is a hint, applications that want to - * verify what size the buffers were set to should call - * {@link #getReceiveBufferSize()}. - *

- * Increasing SO_RCVBUF may allow the network implementation - * to buffer multiple packets when packets arrive faster than - * are being received using {@link #receive()}. - *

- * Note: It is implementation specific if a packet larger - * than SO_RCVBUF can be received. - * - * @param size the size to which to set the receive buffer - * size. This value must be greater than 0. - * - * @exception SocketException if there is an error in - * the underlying protocol, such as an UDP error. - * @exception IllegalArgumentException if the value is 0 or is - * negative. - * @see #getReceiveBufferSize() - */ - public synchronized void setReceiveBufferSize(int size) - throws SocketException{ - if (size <= 0) { - throw new IllegalArgumentException("invalid receive size"); - } - if (isClosed()) - throw new SocketException("Socket is closed"); - getImpl().setOption(SocketOptions.SO_RCVBUF, new Integer(size)); - } - - /** - * Get value of the SO_RCVBUF option for this DatagramSocket, that is the - * buffer size used by the platform for input on this DatagramSocket. - * - * @return the value of the SO_RCVBUF option for this DatagramSocket - * @exception SocketException if there is an error in the underlying protocol, such as an UDP error. - * @see #setReceiveBufferSize(int) - */ - public synchronized int getReceiveBufferSize() - throws SocketException{ - if (isClosed()) - throw new SocketException("Socket is closed"); - int result = 0; - Object o = getImpl().getOption(SocketOptions.SO_RCVBUF); - if (o instanceof Integer) { - result = ((Integer)o).intValue(); - } - return result; - } - - /** - * Enable/disable the SO_REUSEADDR socket option. - *

- * For UDP sockets it may be necessary to bind more than one - * socket to the same socket address. This is typically for the - * purpose of receiving multicast packets - * (See {@link #java.net.MulticastSocket}). The - * SO_REUSEADDR socket option allows multiple - * sockets to be bound to the same socket address if the - * SO_REUSEADDR socket option is enabled prior - * to binding the socket using {@link #bind(SocketAddress)}. - *

- * When a DatagramSocket is created the initial setting - * of SO_REUSEADDR is disabled. - *

- * The behaviour when SO_REUSEADDR is enabled or - * disabled after a socket is bound (See {@link #isBound()}) - * is not defined. - * - * @param on whether to enable or disable the - * @exception SocketException if an error occurs enabling or - * disabling the SO_RESUEADDR socket option, - * or the socket is closed. - * @since 1.4 - * @see #getReuseAddress() - * @see #bind(SocketAddress) - * @see #isBound() - * @see #isClosed() - */ - public synchronized void setReuseAddress(boolean on) throws SocketException { -===================================================================== -Found a 8 line (254 tokens) duplication in the following files: -Starting at line 611 of /usr/local/java/src/java/util/BitSet.java -Starting at line 619 of /usr/local/java/src/java/util/BitSet.java - 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; -===================================================================== -Found a 181 line (248 tokens) duplication in the following files: -Starting at line 456 of /usr/local/java/src/java/awt/Choice.java -Starting at line 388 of /usr/local/java/src/java/awt/Checkbox.java - oldGroup.setSelectedCheckbox(null); - } - } - - /** - * Adds the specified item listener to receive item events from - * this check box. Item events are sent to listeners in response - * to user input, but not in response to calls to setState(). - * If l is null, no exception is thrown and no action is performed. - * - * @param l the item listener - * @see #removeItemListener - * @see #getItemListeners - * @see #setState - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since JDK1.1 - */ - public synchronized void addItemListener(ItemListener l) { - if (l == null) { - return; - } - itemListener = AWTEventMulticaster.add(itemListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified item listener so that the item listener - * no longer receives item events from this check box. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the item listener - * @see #addItemListener - * @see #getItemListeners - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since JDK1.1 - */ - public synchronized void removeItemListener(ItemListener l) { - if (l == null) { - return; - } - itemListener = AWTEventMulticaster.remove(itemListener, l); - } - - /** - * Returns an array of all the item listeners - * registered on this checkbox. - * - * @return all of this checkbox's ItemListeners - * or an empty array if no item - * listeners are currently registered - * - * @see #addItemListener - * @see #removeItemListener - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since 1.4 - */ - public synchronized ItemListener[] getItemListeners() { - return (ItemListener[]) (getListeners(ItemListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this Checkbox. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * Checkbox c - * for its item listeners with the following code: - * - *

ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this checkbox, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getItemListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ItemListener.class) { - l = itemListener; - } else { - return super.getListeners(listenerType); - } - return AWTEventMulticaster.getListeners(l, listenerType); - } - - // REMIND: remove when filtering is done at lower level - boolean eventEnabled(AWTEvent e) { - if (e.id == ItemEvent.ITEM_STATE_CHANGED) { - if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 || - itemListener != null) { - return true; - } - return false; - } - return super.eventEnabled(e); - } - - /** - * Processes events on this check box. - * If the event is an instance of ItemEvent, - * this method invokes the processItemEvent method. - * Otherwise, it calls its superclass's processEvent method. - *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the event - * @see java.awt.event.ItemEvent - * @see #processItemEvent - * @since JDK1.1 - */ - protected void processEvent(AWTEvent e) { - if (e instanceof ItemEvent) { - processItemEvent((ItemEvent)e); - return; - } - super.processEvent(e); - } - - /** - * Processes item events occurring on this check box by - * dispatching them to any registered - * ItemListener objects. - *

- * This method is not called unless item events are - * enabled for this component. Item events are enabled - * when one of the following occurs: - *

    - *
  • An ItemListener object is registered - * via addItemListener. - *
  • Item events are enabled via enableEvents. - *
- *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the item event - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @see #addItemListener - * @see java.awt.Component#enableEvents - * @since JDK1.1 - */ - protected void processItemEvent(ItemEvent e) { - ItemListener listener = itemListener; - if (listener != null) { - listener.itemStateChanged(e); - } - } - - /** - * Returns a string representing the state of this Checkbox. - * This method is intended to be used only for debugging purposes, and the - * content and format of the returned string may vary between - * implementations. The returned string may be empty but may not be - * null. - * - * @return the parameter string of this check box - */ - protected String paramString() { -===================================================================== -Found a 175 line (246 tokens) duplication in the following files: -Starting at line 413 of /usr/local/java/src/java/awt/TextField.java -Starting at line 221 of /usr/local/java/src/java/awt/Button.java - } - - /** - * Adds the specified action listener to receive action events from - * this button. Action events occur when a user presses or releases - * the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so that it no longer - * receives action events from this button. Action events occur - * when a user presses or releases the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this button. - * - * @return all of this button's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event.ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[]) (getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this Button. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * Button b - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this button, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } else { - return super.getListeners(listenerType); - } - return AWTEventMulticaster.getListeners(l, listenerType); - } - - // REMIND: remove when filtering is done at lower level - boolean eventEnabled(AWTEvent e) { - if (e.id == ActionEvent.ACTION_PERFORMED) { - if ((eventMask & AWTEvent.ACTION_EVENT_MASK) != 0 || - actionListener != null) { - return true; - } - return false; - } - return super.eventEnabled(e); - } - - /** - * Processes events on this button. If an event is - * an instance of ActionEvent, this method invokes - * the processActionEvent method. Otherwise, - * it invokes processEvent on the superclass. - *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the event - * @see java.awt.event.ActionEvent - * @see java.awt.Button#processActionEvent - * @since JDK1.1 - */ - protected void processEvent(AWTEvent e) { - if (e instanceof ActionEvent) { - processActionEvent((ActionEvent)e); - return; - } - super.processEvent(e); - } - - /** - * Processes action events occurring on this button - * by dispatching them to any registered - * ActionListener objects. - *

- * This method is not called unless action events are - * enabled for this button. Action events are enabled - * when one of the following occurs: - *

    - *
  • An ActionListener object is registered - * via addActionListener. - *
  • Action events are enabled via enableEvents. - *
- *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the action event - * @see java.awt.event.ActionListener - * @see java.awt.Button#addActionListener - * @see java.awt.Component#enableEvents - * @since JDK1.1 - */ - protected void processActionEvent(ActionEvent e) { - ActionListener listener = actionListener; - if (listener != null) { - listener.actionPerformed(e); - } - } - - /** - * Returns a string representing the state of this Button. - * This method is intended to be used only for debugging purposes, and the - * content and format of the returned string may vary between - * implementations. The returned string may be empty but may not be - * null. - * - * @return the parameter string of this button - */ - protected String paramString() { -===================================================================== -Found a 39 line (244 tokens) duplication in the following files: -Starting at line 381 of /usr/local/java/src/java/lang/Package.java -Starting at line 276 of /usr/local/java/src/java/net/URLClassLoader.java - URL sealBase = null; - - Attributes attr = man.getAttributes(path); - if (attr != null) { - specTitle = attr.getValue(Name.SPECIFICATION_TITLE); - specVersion = attr.getValue(Name.SPECIFICATION_VERSION); - specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); - implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); - implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); - implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); - sealed = attr.getValue(Name.SEALED); - } - attr = man.getMainAttributes(); - if (attr != null) { - if (specTitle == null) { - specTitle = attr.getValue(Name.SPECIFICATION_TITLE); - } - if (specVersion == null) { - specVersion = attr.getValue(Name.SPECIFICATION_VERSION); - } - if (specVendor == null) { - specVendor = attr.getValue(Name.SPECIFICATION_VENDOR); - } - if (implTitle == null) { - implTitle = attr.getValue(Name.IMPLEMENTATION_TITLE); - } - if (implVersion == null) { - implVersion = attr.getValue(Name.IMPLEMENTATION_VERSION); - } - if (implVendor == null) { - implVendor = attr.getValue(Name.IMPLEMENTATION_VENDOR); - } - if (sealed == null) { - sealed = attr.getValue(Name.SEALED); - } - } - if ("true".equalsIgnoreCase(sealed)) { - sealBase = url; - } -===================================================================== -Found a 31 line (242 tokens) duplication in the following files: -Starting at line 257 of /usr/local/java/src/java/text/CharacterBreakData.java -Starting at line 287 of /usr/local/java/src/java/text/CharacterBreakData.java - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // ctrl ctrl ctrl ctrl ctrl ctrl ctrl ctrl - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // ctrl ctrl ctrl ctrl ctrl ctrl ctrl ctrl - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // ctrl ctrl ctrl ctrl ctrl ctrl ctrl ctrl - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // nbsp inv-! cents pounds currency yen broken-bar section - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // umlaut copyright super-a gui-left not soft-hyph registered macron - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // degree +/- super-2 super-3 acute micro paragraph bullet - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // cedilla super-1 super-o gui-right 1/4 1/2 3/4 inv-? - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // A-grave A-acute A-hat A-tilde A-umlaut A-ring AE C-cedilla - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // E-grave E-acute E-hat E-umlaut I-grave I-acute I-hat I-umlaut - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // Edh N-tilde O-grave O-acute O-hat O-tilde O-umlaut times - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // O-slash U-grave U-acute U-hat U-umlaut Y-acute Thorn ess-zed - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // a-grave a-acute a-hat a-tilde a-umlaut a-ring ae c-cedilla - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // e-grave e-acute e-hat e-umlaut i-grave i-acute i-hat i-umlaut - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // edh n-tilde o-grave o-acute o-hat o-tilde o-umlaut over - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, - // o-slash u-grave u-acute u-hat u-umlaut y-acute thorn y-umlaut - baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm, baseForm -===================================================================== -Found a 170 line (240 tokens) duplication in the following files: -Starting at line 458 of /usr/local/java/src/java/awt/Choice.java -Starting at line 193 of /usr/local/java/src/java/awt/CheckboxMenuItem.java - } - - /** - * Adds the specified item listener to receive item events from - * this check box menu item. Item events are sent in response to user - * actions, but not in response to calls to setState(). - * If l is null, no exception is thrown and no action is performed. - * - * @param l the item listener - * @see #removeItemListener - * @see #getItemListeners - * @see #setState - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since JDK1.1 - */ - public synchronized void addItemListener(ItemListener l) { - if (l == null) { - return; - } - itemListener = AWTEventMulticaster.add(itemListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified item listener so that it no longer receives - * item events from this check box menu item. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the item listener - * @see #addItemListener - * @see #getItemListeners - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since JDK1.1 - */ - public synchronized void removeItemListener(ItemListener l) { - if (l == null) { - return; - } - itemListener = AWTEventMulticaster.remove(itemListener, l); - } - - /** - * Returns an array of all the item listeners - * registered on this checkbox menuitem. - * - * @return all of this checkbox menuitem's ItemListeners - * or an empty array if no item - * listeners are currently registered - * - * @see #addItemListener - * @see #removeItemListener - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @since 1.4 - */ - public synchronized ItemListener[] getItemListeners() { - return (ItemListener[])(getListeners(ItemListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this CheckboxMenuItem. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * CheckboxMenuItem c - * for its item listeners with the following code: - * - *

ItemListener[] ils = (ItemListener[])(c.getListeners(ItemListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this checkbox menuitem, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getItemListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ItemListener.class) { - l = itemListener; - } else { - return super.getListeners(listenerType); - } - return AWTEventMulticaster.getListeners(l, listenerType); - } - - // REMIND: remove when filtering is done at lower level - boolean eventEnabled(AWTEvent e) { - if (e.id == ItemEvent.ITEM_STATE_CHANGED) { - if ((eventMask & AWTEvent.ITEM_EVENT_MASK) != 0 || - itemListener != null) { - return true; - } - return false; - } - return super.eventEnabled(e); - } - - /** - * Processes events on this check box menu item. - * If the event is an instance of ItemEvent, - * this method invokes the processItemEvent method. - * If the event is not an item event, - * it invokes processEvent on the superclass. - *

- * Check box menu items currently support only item events. - *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the event - * @see java.awt.event.ItemEvent - * @see #processItemEvent - * @since JDK1.1 - */ - protected void processEvent(AWTEvent e) { - if (e instanceof ItemEvent) { - processItemEvent((ItemEvent)e); - return; - } - super.processEvent(e); - } - - /** - * Processes item events occurring on this check box menu item by - * dispatching them to any registered ItemListener objects. - *

- * This method is not called unless item events are - * enabled for this menu item. Item events are enabled - * when one of the following occurs: - *

    - *
  • An ItemListener object is registered - * via addItemListener. - *
  • Item events are enabled via enableEvents. - *
- *

Note that if the event parameter is null - * the behavior is unspecified and may result in an - * exception. - * - * @param e the item event - * @see java.awt.event.ItemEvent - * @see java.awt.event.ItemListener - * @see #addItemListener - * @see java.awt.MenuItem#enableEvents - * @since JDK1.1 - */ - protected void processItemEvent(ItemEvent e) { - ItemListener listener = itemListener; - if (listener != null) { - listener.itemStateChanged(e); - } - } -===================================================================== -Found a 36 line (229 tokens) duplication in the following files: -Starting at line 495 of /usr/local/java/src/java/util/Arrays.java -Starting at line 578 of /usr/local/java/src/java/util/Arrays.java -Starting at line 661 of /usr/local/java/src/java/util/Arrays.java -Starting at line 745 of /usr/local/java/src/java/util/Arrays.java -Starting at line 829 of /usr/local/java/src/java/util/Arrays.java -Starting at line 913 of /usr/local/java/src/java/util/Arrays.java -Starting at line 997 of /usr/local/java/src/java/util/Arrays.java - float v = x[m]; - - // Establish Invariant: v* (v)* v* - int a = off, b = a, c = off + len - 1, d = c; - while(true) { - while (b <= c && x[b] <= v) { - if (x[b] == v) - swap(x, a++, b); - b++; - } - while (c >= b && x[c] >= v) { - if (x[c] == v) - swap(x, c, d--); - c--; - } - if (b > c) - break; - swap(x, b++, c--); - } - - // Swap partition elements back to middle - int s, n = off + len; - s = Math.min(a-off, b-a ); vecswap(x, off, b-s, s); - s = Math.min(d-c, n-d-1); vecswap(x, b, n-s, s); - - // Recursively sort non-partition-elements - if ((s = b-a) > 1) - sort1(x, off, s); - if ((s = d-c) > 1) - sort1(x, n-s, s); - } - - /** - * Swaps x[a] with x[b]. - */ - private static void swap(float x[], int a, int b) { -===================================================================== -Found a 52 line (224 tokens) duplication in the following files: -Starting at line 925 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 593 of /usr/local/java/src/java/awt/image/BandedSampleModel.java - sarray[i] & 0xffff); - } - break; - - case DataBuffer.TYPE_INT: - - int[] iarray = (int[])obj; - - for (int i=0; i= width) || (y >= height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - int pixelOffset = y*scanlineStride + x; -===================================================================== -Found a 47 line (209 tokens) duplication in the following files: -Starting at line 473 of /usr/local/java/src/java/security/UnresolvedPermission.java -Starting at line 431 of /usr/local/java/src/java/security/CodeSource.java - ois.defaultReadObject(); - - // process any new-style certs in the stream (if present) - int size = ois.readInt(); - if (size > 0) { - // we know of 3 different cert types: X.509, PGP, SDSI, which - // could all be present in the stream at the same time - cfs = new Hashtable(3); - this.certs = new java.security.cert.Certificate[size]; - } - - for (int i=0; i rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public FloatBuffer put(float[] src, int offset, int length) { -===================================================================== -Found a 37 line (199 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - DirectDoubleBufferU sb = (DirectDoubleBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public DoubleBuffer put(double[] src, int offset, int length) { -===================================================================== -Found a 37 line (199 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - DirectFloatBufferS sb = (DirectFloatBufferS)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 2); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public FloatBuffer put(float[] src, int offset, int length) { -===================================================================== -Found a 37 line (199 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectLongBufferU.java - DirectLongBufferU sb = (DirectLongBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 3); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public LongBuffer put(long[] src, int offset, int length) { -===================================================================== -Found a 37 line (199 tokens) duplication in the following files: -Starting at line 265 of /usr/local/java/src/java/nio/DirectCharBufferU.java -Starting at line 265 of /usr/local/java/src/java/nio/DirectShortBufferU.java - DirectShortBufferU sb = (DirectShortBufferU)src; - - int spos = sb.position(); - int slim = sb.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - if (srem > rem) - throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), srem << 1); - sb.position(spos + srem); - position(pos + srem); - } else if (!src.isDirect()) { - - int spos = src.position(); - int slim = src.limit(); - assert (spos <= slim); - int srem = (spos <= slim ? slim - spos : 0); - - put(src.hb, src.offset + spos, srem); - src.position(spos + srem); - - } else { - super.put(src); - } - return this; - - - - } - - public ShortBuffer put(short[] src, int offset, int length) { -===================================================================== -Found a 40 line (198 tokens) duplication in the following files: -Starting at line 863 of /usr/local/java/src/java/awt/image/Raster.java -Starting at line 951 of /usr/local/java/src/java/awt/image/Raster.java - public static WritableRaster createWritableRaster(SampleModel sm, - DataBuffer db, - Point location) { - if ((sm == null) || (db == null)) { - throw new NullPointerException("SampleModel and DataBuffer cannot be null"); - } - if (location == null) { - location = new Point(0,0); - } - - int dataType = sm.getDataType(); - - if (sm instanceof PixelInterleavedSampleModel) { - switch(dataType) { - case DataBuffer.TYPE_BYTE: - return new ByteInterleavedRaster(sm, db, location); - - case DataBuffer.TYPE_USHORT: - return new ShortInterleavedRaster(sm, db, location); - } - } else if (sm instanceof SinglePixelPackedSampleModel) { - switch(dataType) { - case DataBuffer.TYPE_BYTE: - return new ByteInterleavedRaster(sm, db, location); - - case DataBuffer.TYPE_USHORT: - return new ShortInterleavedRaster(sm, db, location); - - case DataBuffer.TYPE_INT: - return new IntegerInterleavedRaster(sm, db, location); - } - } else if (sm instanceof MultiPixelPackedSampleModel && - dataType == DataBuffer.TYPE_BYTE && - sm.getSampleSize(0) < 8) { - return new BytePackedRaster(sm, db, location); - } - - // we couldn't do anything special - do the generic thing - - return new SunWritableRaster(sm,db,location); -===================================================================== -Found a 38 line (195 tokens) duplication in the following files: -Starting at line 437 of /usr/local/java/src/java/awt/Container.java -Starting at line 627 of /usr/local/java/src/java/awt/Container.java - if (index > ncomponents) { - throw new IllegalArgumentException("illegal component position"); - } - } - - /* Add component to list; allocate new array if necessary. */ - if (ncomponents == component.length) { - Component newcomponents[] = new Component[ncomponents * 2 + 1]; - System.arraycopy(component, 0, newcomponents, 0, ncomponents); - component = newcomponents; - } - if (index == -1 || index == ncomponents) { - component[ncomponents++] = comp; - } else { - System.arraycopy(component, index, component, - index + 1, ncomponents - index); - component[index] = comp; - ncomponents++; - } - comp.parent = this; - - adjustListeningChildren(AWTEvent.HIERARCHY_EVENT_MASK, - comp.numListening(AWTEvent.HIERARCHY_EVENT_MASK)); - adjustListeningChildren(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK, - comp.numListening(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK)); - adjustDescendants(comp.countHierarchyMembers()); - - if (valid) { - invalidate(); - } - if (peer != null) { - comp.addNotify(); - } - - /* Notify the layout manager of the added component. */ - if (layoutMgr != null) { - if (layoutMgr instanceof LayoutManager2) { - ((LayoutManager2)layoutMgr).addLayoutComponent(comp, constraints); -===================================================================== -Found a 69 line (193 tokens) duplication in the following files: -Starting at line 90 of /usr/local/java/src/java/io/InputStream.java -Starting at line 92 of /usr/local/java/src/java/io/LineNumberInputStream.java - } - - /** - * Reads up to len bytes of data from this input stream - * into an array of bytes. This method blocks until some input is available. - *

- * The read method of - * LineNumberInputStream repeatedly calls the - * read method of zero arguments to fill in the byte array. - * - * @param b the buffer into which the data is read. - * @param off the start offset of the data. - * @param len the maximum number of bytes read. - * @return the total number of bytes read into the buffer, or - * -1 if there is no more data because the end of - * this stream has been reached. - * @exception IOException if an I/O error occurs. - * @see java.io.LineNumberInputStream#read() - */ - public int read(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - - int c = read(); - if (c == -1) { - return -1; - } - b[off] = (byte)c; - - int i = 1; - try { - for (; i < len ; i++) { - c = read(); - if (c == -1) { - break; - } - if (b != null) { - b[off + i] = (byte)c; - } - } - } catch (IOException ee) { - } - return i; - } - - /** - * Skips over and discards n bytes of data from this - * input stream. The skip method may, for a variety of - * reasons, end up skipping over some smaller number of bytes, - * possibly 0. The actual number of bytes skipped is - * returned. If n is negative, no bytes are skipped. - *

- * The skip method of LineNumberInputStream creates - * a byte array and then repeatedly reads into it until - * n bytes have been read or the end of the stream has - * been reached. - * - * @param n the number of bytes to be skipped. - * @return the actual number of bytes skipped. - * @exception IOException if an I/O error occurs. - * @see java.io.FilterInputStream#in - */ - public long skip(long n) throws IOException { -===================================================================== -Found a 61 line (193 tokens) duplication in the following files: -Starting at line 1444 of /usr/local/java/src/java/awt/geom/CubicCurve2D.java -Starting at line 1094 of /usr/local/java/src/java/awt/geom/QuadCurve2D.java - y1, ctrly, y2) == 2 && - getTag(res[0], y, y+h) * getTag(res[1], y, y+h) <= 0); - } - - // The X and Y ranges of the endpoints overlap the X and Y - // ranges of the rectangle, now find out how the endpoint - // line segment intersects the Y range of the rectangle - double dx = x2 - x1; - double dy = y2 - y1; - double k = y2 * x1 - x2 * y1; - int c1tag, c2tag; - if (y1tag == INSIDE) { - c1tag = x1tag; - } else { - c1tag = getTag((k + dx * (y1tag < INSIDE ? y : y+h)) / dy, x, x+w); - } - if (y2tag == INSIDE) { - c2tag = x2tag; - } else { - c2tag = getTag((k + dx * (y2tag < INSIDE ? y : y+h)) / dy, x, x+w); - } - // If the part of the line segment that intersects the Y range - // of the rectangle crosses it horizontally - trivially accept - if (c1tag * c2tag <= 0) { - return true; - } - - // Now we know that both the X and Y ranges intersect and that - // the endpoint line segment does not directly cross the rectangle. - // - // We can almost treat this case like one of the cases above - // where both endpoints are to one side, except that we will - // only get one intersection of the curve with the vertical - // side of the rectangle. This is because the endpoint segment - // accounts for the other intersection. - // - // (Remember there is overlap in both the X and Y ranges which - // means that the segment must cross at least one vertical edge - // of the rectangle - in particular, the "near vertical side" - - // leaving only one intersection for the curve.) - // - // Now we calculate the y tags of the two intersections on the - // "near vertical side" of the rectangle. We will have one with - // the endpoint segment, and one with the curve. If those two - // vertical intersections overlap the Y range of the rectangle, - // we have an intersection. Otherwise, we don't. - - // c1tag = vertical intersection class of the endpoint segment - // - // Choose the y tag of the endpoint that was not on the same - // side of the rectangle as the subsegment calculated above. - // Note that we can "steal" the existing Y tag of that endpoint - // since it will be provably the same as the vertical intersection. - c1tag = ((c1tag * x1tag <= 0) ? y1tag : y2tag); - - // c2tag = vertical intersection class of the curve - // - // We have to calculate this one the straightforward way. - // Note that the c2tag can still tell us which vertical edge - // to test against. - fillEqn(eqn, (c2tag < INSIDE ? x : x+w), x1, ctrlx, x2); -===================================================================== -Found a 35 line (193 tokens) duplication in the following files: -Starting at line 146 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferB.java -Starting at line 146 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferRB.java - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); - return new ByteBufferAsCharBufferRB(bb, -1, 0, sublen, sublen, off); -===================================================================== -Found a 44 line (191 tokens) duplication in the following files: -Starting at line 132 of /usr/local/java/src/java/awt/image/LookupOp.java -Starting at line 336 of /usr/local/java/src/java/awt/image/RescaleOp.java - int width = src.getWidth(); - int height = src.getHeight(); - - if (dst == null) { - dst = createCompatibleDestImage(src, null); - dstCM = srcCM; - } - else { - if (width != dst.getWidth()) { - throw new - IllegalArgumentException("Src width ("+width+ - ") not equal to dst width ("+ - dst.getWidth()+")"); - } - if (height != dst.getHeight()) { - throw new - IllegalArgumentException("Src height ("+height+ - ") not equal to dst height ("+ - dst.getHeight()+")"); - } - - dstCM = dst.getColorModel(); - if(srcCM.getColorSpace().getType() != - dstCM.getColorSpace().getType()) { - needToConvert = true; - dst = createCompatibleDestImage(src, null); - } - - } - - BufferedImage origDst = dst; - - // - // Try to use a native BI rescale operation first - // - if (ImagingLib.filter(this, src, dst) == null) { - // - // Native BI rescale failed - convert to rasters - // - WritableRaster srcRaster = src.getRaster(); - WritableRaster dstRaster = dst.getRaster(); - - if (srcCM.hasAlpha()) { - if (numBands-1 == length || length == 1) { -===================================================================== -Found a 37 line (191 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectShortBufferU.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectShortBufferS.java - return (Bits.swap(unsafe.getShort(ix(checkIndex(i))))); - } - - public ShortBuffer get(short[] dst, int offset, int length) { - - if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToShortArray(ix(pos), dst, - offset << 1, - length << 1); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 1, - length << 1); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public ShortBuffer put(short x) { - - unsafe.putShort(ix(nextPutIndex()), Bits.swap((x))); -===================================================================== -Found a 37 line (191 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectLongBufferS.java - return (Bits.swap(unsafe.getLong(ix(checkIndex(i))))); - } - - public LongBuffer get(long[] dst, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToLongArray(ix(pos), dst, - offset << 3, - length << 3); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 3, - length << 3); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public LongBuffer put(long x) { - - unsafe.putLong(ix(nextPutIndex()), Bits.swap((x))); -===================================================================== -Found a 37 line (191 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectIntBufferU.java - return ((unsafe.getInt(ix(checkIndex(i))))); - } - - public IntBuffer get(int[] dst, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToIntArray(ix(pos), dst, - offset << 2, - length << 2); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 2, - length << 2); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public IntBuffer put(int x) { - - unsafe.putInt(ix(nextPutIndex()), ((x))); -===================================================================== -Found a 37 line (191 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectCharBufferU.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectCharBufferS.java - return (Bits.swap(unsafe.getChar(ix(checkIndex(i))))); - } - - public CharBuffer get(char[] dst, int offset, int length) { - - if ((length << 1) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToCharArray(ix(pos), dst, - offset << 1, - length << 1); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 1, - length << 1); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public CharBuffer put(char x) { - - unsafe.putChar(ix(nextPutIndex()), Bits.swap((x))); -===================================================================== -Found a 38 line (189 tokens) duplication in the following files: -Starting at line 346 of /usr/local/java/src/java/nio/DirectCharBufferRU.java -Starting at line 142 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferRB.java - } - - public boolean isReadOnly() { - return true; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); -===================================================================== -Found a 36 line (189 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferS.java -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferRU.java - } - - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = (pos + start) << 1; - return new DirectCharBufferRU(this, -1, 0, sublen, sublen, off); -===================================================================== -Found a 38 line (189 tokens) duplication in the following files: -Starting at line 346 of /usr/local/java/src/java/nio/DirectCharBufferS.java -Starting at line 142 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferB.java - } - - public boolean isReadOnly() { - return false; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); -===================================================================== -Found a 36 line (189 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferU.java -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferRU.java - } - - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = (pos + start) << 1; - return new DirectCharBufferRU(this, -1, 0, sublen, sublen, off); -===================================================================== -Found a 38 line (189 tokens) duplication in the following files: -Starting at line 346 of /usr/local/java/src/java/nio/DirectCharBufferU.java -Starting at line 142 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferB.java - } - - public boolean isReadOnly() { - return false; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); -===================================================================== -Found a 36 line (189 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferRS.java -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferU.java - } - - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = (pos + start) << 1; - return new DirectCharBufferU(this, -1, 0, sublen, sublen, off); -===================================================================== -Found a 38 line (189 tokens) duplication in the following files: -Starting at line 346 of /usr/local/java/src/java/nio/DirectCharBufferRS.java -Starting at line 142 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferRB.java - } - - public boolean isReadOnly() { - return true; - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); -===================================================================== -Found a 31 line (183 tokens) duplication in the following files: -Starting at line 262 of /usr/local/java/src/java/lang/CharacterData.java -Starting at line 157 of /usr/local/java/src/java/lang/CharacterDataLatin1.java - } - - static int digit(char ch, int radix) { - int value = -1; - if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) { - int val = getProperties(ch); - int kind = val & 0x1F; - if (kind == Character.DECIMAL_DIGIT_NUMBER) { - value = ch + ((val & 0x3E0) >> 5) & 0x1F; - } - else if ((val & 0xC00) == 0x00000C00) { - // Java supradecimal digit - value = (ch + ((val & 0x3E0) >> 5) & 0x1F) + 10; - } - } - return (value < radix) ? value : -1; - } - - static int getNumericValue(char ch) { - int val = getProperties(ch); - int retval = -1; - - switch (val & 0xC00) { - default: // cannot occur - case (0x00000000): // not numeric - retval = -1; - break; - case (0x00000400): // simple numeric - retval = ch + ((val & 0x3E0) >> 5) & 0x1F; - break; - case (0x00000800) : // "strange" numeric -===================================================================== -Found a 59 line (180 tokens) duplication in the following files: -Starting at line 150 of /usr/local/java/src/java/io/PipedReader.java -Starting at line 176 of /usr/local/java/src/java/io/PipedInputStream.java - receive(b[off++]); - } - } - - /** - * Notifies all waiting threads that the last byte of data has been - * received. - */ - synchronized void receivedLast() { - closedByWriter = true; - notifyAll(); - } - - /** - * Reads the next byte of data from this piped input stream. The - * value byte is returned as an int in the range - * 0 to 255. If no byte is available - * because the end of the stream has been reached, the value - * -1 is returned. This method blocks until input data - * is available, the end of the stream is detected, or an exception - * is thrown. - * If a thread was providing data bytes - * to the connected piped output stream, but - * the thread is no longer alive, then an - * IOException is thrown. - * - * @return the next byte of data, or -1 if the end of the - * stream is reached. - * @exception IOException if the pipe is broken. - */ - public synchronized int read() throws IOException { - if (!connected) { - throw new IOException("Pipe not connected"); - } else if (closedByReader) { - throw new IOException("Pipe closed"); - } else if (writeSide != null && !writeSide.isAlive() - && !closedByWriter && (in < 0)) { - throw new IOException("Write end dead"); - } - - readSide = Thread.currentThread(); - int trials = 2; - while (in < 0) { - if (closedByWriter) { - /* closed by writer, return EOF */ - return -1; - } - if ((writeSide != null) && (!writeSide.isAlive()) && (--trials < 0)) { - throw new IOException("Pipe broken"); - } - /* might be a writer waiting */ - notifyAll(); - try { - wait(1000); - } catch (InterruptedException ex) { - throw new java.io.InterruptedIOException(); - } - } - int ret = buffer[out++] & 0xFF; -===================================================================== -Found a 34 line (180 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/nio/DirectCharBufferRS.java -Starting at line 146 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferL.java - } - - - - public String toString(int start, int end) { - if ((end > limit()) || (start > end)) - throw new IndexOutOfBoundsException(); - try { - int len = end - start; - char[] ca = new char[len]; - CharBuffer cb = CharBuffer.wrap(ca); - CharBuffer db = this.duplicate(); - db.position(start); - db.limit(end); - cb.put(db); - return new String(ca); - } catch (StringIndexOutOfBoundsException x) { - throw new IndexOutOfBoundsException(); - } - } - - - // --- Methods to support CharSequence --- - - public CharSequence subSequence(int start, int end) { - int len = length(); - int pos = position(); - assert (pos <= len); - pos = (pos <= len ? pos : len); - - if ((start < 0) || (end > len) || (start > end)) - throw new IndexOutOfBoundsException(); - int sublen = end - start; - int off = offset + ((pos + start) << 1); -===================================================================== -Found a 37 line (178 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectFloatBufferS.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectFloatBufferU.java - return ((unsafe.getFloat(ix(checkIndex(i))))); - } - - public FloatBuffer get(float[] dst, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToIntArray(ix(pos), dst, - offset << 2, - length << 2); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 2, - length << 2); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public FloatBuffer put(float x) { - - unsafe.putFloat(ix(nextPutIndex()), ((x))); -===================================================================== -Found a 37 line (178 tokens) duplication in the following files: -Starting at line 208 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 208 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - return ((unsafe.getDouble(ix(checkIndex(i))))); - } - - public DoubleBuffer get(double[] dst, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToLongArray(ix(pos), dst, - offset << 3, - length << 3); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 3, - length << 3); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public DoubleBuffer put(double x) { - - unsafe.putDouble(ix(nextPutIndex()), ((x))); -===================================================================== -Found a 56 line (177 tokens) duplication in the following files: -Starting at line 388 of /usr/local/java/src/java/lang/Long.java -Starting at line 462 of /usr/local/java/src/java/lang/Integer.java - limit = -Integer.MAX_VALUE; - } - multmin = limit / radix; - if (i < max) { - digit = Character.digit(s.charAt(i++),radix); - if (digit < 0) { - throw NumberFormatException.forInputString(s); - } else { - result = -digit; - } - } - while (i < max) { - // Accumulating negatively avoids surprises near MAX_VALUE - digit = Character.digit(s.charAt(i++),radix); - if (digit < 0) { - throw NumberFormatException.forInputString(s); - } - if (result < multmin) { - throw NumberFormatException.forInputString(s); - } - result *= radix; - if (result < limit + digit) { - throw NumberFormatException.forInputString(s); - } - result -= digit; - } - } else { - throw NumberFormatException.forInputString(s); - } - if (negative) { - if (i > 1) { - return result; - } else { /* Only got "-" */ - throw NumberFormatException.forInputString(s); - } - } else { - return -result; - } - } - - /** - * Parses the string argument as a signed decimal integer. The - * characters in the string must all be decimal digits, except that - * the first character may be an ASCII minus sign '-' - * ('\u002D') to indicate a negative value. The resulting - * integer value is returned, exactly as if the argument and the radix - * 10 were given as arguments to the - * {@link #parseInt(java.lang.String, int)} method. - * - * @param s a String containing the int - * representation to be parsed - * @return the integer value represented by the argument in decimal. - * @exception NumberFormatException if the string does not contain a - * parsable integer. - */ - public static int parseInt(String s) throws NumberFormatException { -===================================================================== -Found a 22 line (177 tokens) duplication in the following files: -Starting at line 473 of /usr/local/java/src/java/util/Arrays.java -Starting at line 556 of /usr/local/java/src/java/util/Arrays.java -Starting at line 639 of /usr/local/java/src/java/util/Arrays.java -Starting at line 723 of /usr/local/java/src/java/util/Arrays.java -Starting at line 807 of /usr/local/java/src/java/util/Arrays.java -Starting at line 891 of /usr/local/java/src/java/util/Arrays.java -Starting at line 975 of /usr/local/java/src/java/util/Arrays.java - private static void sort1(float x[], int off, int len) { - // Insertion sort on smallest arrays - if (len < 7) { - for (int i=off; ioff && x[j-1]>x[j]; j--) - swap(x, j, j-1); - return; - } - - // Choose a partition element, v - int m = off + (len >> 1); // Small arrays, middle element - if (len > 7) { - int l = off; - int n = off + len - 1; - if (len > 40) { // Big arrays, pseudomedian of 9 - int s = len/8; - l = med3(x, l, l+s, l+2*s); - m = med3(x, m-s, m, m+s); - n = med3(x, n-2*s, n-s, n); - } - m = med3(x, l, m, n); // Mid-size, med of 3 - } -===================================================================== -Found a 31 line (174 tokens) duplication in the following files: -Starting at line 405 of /usr/local/java/src/java/awt/TexturePaintContext.java -Starting at line 541 of /usr/local/java/src/java/awt/TexturePaintContext.java - for (int j = 0; j < h; j++) { - if (normalx) { - int in = inOff + rowy * inSpan + bWidth; - x = bWidth - rowx; - out += w; - if (bWidth >= 32) { - int i = w; - while (i > 0) { - int copyw = (i < x) ? i : x; - System.arraycopy(inData, in - x, - outData, out - i, - copyw); - i -= copyw; - if ((x -= copyw) == 0) { - x = bWidth; - } - } - } else { - for (int i = w; i > 0; i--) { - outData[out - i] = inData[in - x]; - if (--x == 0) { - x = bWidth; - } - } - } - } else { - x = rowx; - y = rowy; - xerr = rowxerr; - yerr = rowyerr; - for (int i = 0; i < w; i++) { -===================================================================== -Found a 39 line (167 tokens) duplication in the following files: -Starting at line 694 of /usr/local/java/src/java/lang/FloatingDecimal.java -Starting at line 747 of /usr/local/java/src/java/lang/FloatingDecimal.java - low = (b < m ); - high = (b+m > tens ); - assert q < 10 : q; // excessively large digit - if ( (q == 0) && ! high ){ - // oops. Usually ignore leading zero. - decExp--; - } else { - digits[ndigit++] = (char)('0' + q); - } - /* - * HACK! Java spec sez that we always have at least - * one digit after the . in either F- or E-form output. - * Thus we will need more than one digit if we're using - * E-form - */ - if ( decExp <= -3 || decExp >= 8 ){ - high = low = false; - } - while( ! low && ! high ){ - q = (int) ( b / s ); - b = 10 * ( b % s ); - m *= 10; - assert q < 10 : q; // excessively large digit - if ( m > 0L ){ - low = (b < m ); - high = (b+m > tens ); - } else { - // hack -- m might overflow! - // in this case, it is certainly > b, - // which won't - // and b+m > tens, too, since that has overflowed - // either! - low = true; - high = true; - } - digits[ndigit++] = (char)('0' + q); - } - lowDigitDifference = (b<<1) - tens; - } -===================================================================== -Found a 51 line (166 tokens) duplication in the following files: -Starting at line 417 of /usr/local/java/src/java/security/UnresolvedPermission.java -Starting at line 381 of /usr/local/java/src/java/security/CodeSource.java - return sb.toString(); - } - - /** - * Writes this object out to a stream (i.e., serializes it). - * - * @serialData An initial URL is followed by an - * int indicating the number of certificates to follow - * (a value of "zero" denotes that there are no certificates associated - * with this object). - * Each certificate is written out starting with a String - * denoting the certificate type, followed by an - * int specifying the length of the certificate encoding, - * followed by the certificate encoding itself which is written out as an - * array of bytes. - */ - private synchronized void writeObject(java.io.ObjectOutputStream oos) - throws IOException - { - oos.defaultWriteObject(); - - if (certs==null || certs.length==0) { - oos.writeInt(0); - } else { - // write out the total number of certs - oos.writeInt(certs.length); - // write out each cert, including its type - for (int i=0; i < certs.length; i++) { - java.security.cert.Certificate cert = certs[i]; - try { - oos.writeUTF(cert.getType()); - byte[] encoded = cert.getEncoded(); - oos.writeInt(encoded.length); - oos.write(encoded); - } catch (CertificateEncodingException cee) { - throw new IOException(cee.getMessage()); - } - } - } - } - - /** - * Restores this object from a stream (i.e., deserializes it). - */ - private synchronized void readObject(java.io.ObjectInputStream ois) - throws IOException, ClassNotFoundException - { - CertificateFactory cf; - Hashtable cfs=null; - - ois.defaultReadObject(); -===================================================================== -Found a 54 line (164 tokens) duplication in the following files: -Starting at line 138 of /usr/local/java/src/java/util/zip/Deflater.java -Starting at line 86 of /usr/local/java/src/java/util/zip/Inflater.java - this(false); - } - - /** - * Sets input data for decompression. Should be called whenever - * needsInput() returns true indicating that more input data is - * required. - * @param b the input data bytes - * @param off the start offset of the input data - * @param len the length of the input data - * @see Inflater#needsInput - */ - public synchronized void setInput(byte[] b, int off, int len) { - if (b == null) { - throw new NullPointerException(); - } - if (off < 0 || len < 0 || off > b.length - len) { - throw new ArrayIndexOutOfBoundsException(); - } - this.buf = b; - this.off = off; - this.len = len; - } - - /** - * Sets input data for decompression. Should be called whenever - * needsInput() returns true indicating that more input data is - * required. - * @param b the input data bytes - * @see Inflater#needsInput - */ - public void setInput(byte[] b) { - setInput(b, 0, b.length); - } - - /** - * Sets the preset dictionary to the given array of bytes. Should be - * called when inflate() returns 0 and needsDictionary() returns true - * indicating that a preset dictionary is required. The method getAdler() - * can be used to get the Adler-32 value of the dictionary needed. - * @param b the dictionary data bytes - * @param off the start offset of the data - * @param len the length of the data - * @see Inflater#needsDictionary - * @see Inflater#getAdler - */ - public synchronized void setDictionary(byte[] b, int off, int len) { - if (strm == 0 || b == null) { - throw new NullPointerException(); - } - if (off < 0 || len < 0 || off > b.length - len) { - throw new ArrayIndexOutOfBoundsException(); - } - setDictionary(strm, b, off, len); -===================================================================== -Found a 42 line (162 tokens) duplication in the following files: -Starting at line 145 of /usr/local/java/src/java/awt/image/BufferedImageFilter.java -Starting at line 232 of /usr/local/java/src/java/awt/image/BufferedImageFilter.java - ColorModel model, int pixels[], int off, - int scansize) { - // Fix 4184230 - if (w < 0 || h < 0) { - throw new IllegalArgumentException("Width ("+w+ - ") and height ("+h+ - ") must be > 0"); - } - // Nothing to do - if (w == 0 || h == 0) { - return; - } - if (y < 0) { - int diff = -y; - if (diff >= h) { - return; - } - off += scansize * diff; - y += diff; - h -= diff; - } - if (y + h > height) { - h = height - y; - if (h <= 0) { - return; - } - } - if (x < 0) { - int diff = -x; - if (diff >= w) { - return; - } - off += diff; - x += diff; - w -= diff; - } - if (x + w > width) { - w = width - x; - if (w <= 0) { - return; - } - } -===================================================================== -Found a 78 line (154 tokens) duplication in the following files: -Starting at line 195 of /usr/local/java/src/java/lang/reflect/Constructor.java -Starting at line 228 of /usr/local/java/src/java/lang/reflect/Method.java - sb.append(getName() + "("); - Class[] params = parameterTypes; // avoid clone - for (int j = 0; j < params.length; j++) { - sb.append(Field.getTypeName(params[j])); - if (j < (params.length - 1)) - sb.append(","); - } - sb.append(")"); - Class[] exceptions = exceptionTypes; // avoid clone - if (exceptions.length > 0) { - sb.append(" throws "); - for (int k = 0; k < exceptions.length; k++) { - sb.append(exceptions[k].getName()); - if (k < (exceptions.length - 1)) - sb.append(","); - } - } - return sb.toString(); - } catch (Exception e) { - return "<" + e + ">"; - } - } - - /** - * Invokes the underlying method represented by this Method - * object, on the specified object with the specified parameters. - * Individual parameters are automatically unwrapped to match - * primitive formal parameters, and both primitive and reference - * parameters are subject to method invocation conversions as - * necessary. - * - *

If the underlying method is static, then the specified obj - * argument is ignored. It may be null. - * - *

If the number of formal parameters required by the underlying method is - * 0, the supplied args array may be of length 0 or null. - * - *

If the underlying method is an instance method, it is invoked - * using dynamic method lookup as documented in The Java Language - * Specification, Second Edition, section 15.12.4.4; in particular, - * overriding based on the runtime type of the target object will occur. - * - *

If the underlying method is static, the class that declared - * the method is initialized if it has not already been initialized. - * - *

If the method completes normally, the value it returns is - * returned to the caller of invoke; if the value has a primitive - * type, it is first appropriately wrapped in an object. If the - * underlying method return type is void, the invocation returns - * null. - * - * @param obj the object the underlying method is invoked from - * @param args the arguments used for the method call - * @return the result of dispatching the method represented by - * this object on obj with parameters - * args - * - * @exception IllegalAccessException if this Method object - * enforces Java language access control and the underlying - * method is inaccessible. - * @exception IllegalArgumentException if the method is an - * instance method and the specified object argument - * is not an instance of the class or interface - * declaring the underlying method (or of a subclass - * or implementor thereof); if the number of actual - * and formal parameters differ; if an unwrapping - * conversion for primitive arguments fails; or if, - * after possible unwrapping, a parameter value - * cannot be converted to the corresponding formal - * parameter type by a method invocation conversion. - * @exception InvocationTargetException if the underlying method - * throws an exception. - * @exception NullPointerException if the specified object is null - * and the method is an instance method. - * @exception ExceptionInInitializerError if the initialization - * provoked by this method fails. - */ - public Object invoke(Object obj, Object[] args) -===================================================================== -Found a 24 line (154 tokens) duplication in the following files: -Starting at line 1183 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 1206 of /usr/local/java/src/java/awt/image/DirectColorModel.java - case DataBuffer.TYPE_USHORT: { - for (int y = 0; y < h; y++, rY++) { - rX = rminX; - for (int x = 0; x < w; x++, rX++) { - pixel = raster.getPixel(rX, rY, pixel); - normAlpha = pixel[aIdx] * alphaScale; - if (normAlpha != 0.f) { - for (int c=0; c < aIdx; c++) { - pixel[c] = (int) (pixel[c] * normAlpha + - 0.5f); - } - raster.setPixel(rX, rY, pixel); - } else { - if (zpixel == null) { - zpixel = new int[numComponents]; - java.util.Arrays.fill(zpixel, 0); - } - raster.setPixel(rX, rY, zpixel); - } - } - } - } - break; - case DataBuffer.TYPE_INT: { -===================================================================== -Found a 28 line (152 tokens) duplication in the following files: -Starting at line 301 of /usr/local/java/src/java/nio/DirectIntBufferU.java -Starting at line 301 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - public FloatBuffer put(float[] src, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromIntArray(src, offset << 2, - ix(pos), length << 2); - else - Bits.copyFromByteArray(src, offset << 2, - ix(pos), length << 2); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public FloatBuffer compact() { -===================================================================== -Found a 32 line (152 tokens) duplication in the following files: -Starting at line 211 of /usr/local/java/src/java/nio/DirectIntBufferU.java -Starting at line 211 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - public FloatBuffer get(float[] dst, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToIntArray(ix(pos), dst, - offset << 2, - length << 2); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 2, - length << 2); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public FloatBuffer put(float x) { -===================================================================== -Found a 28 line (152 tokens) duplication in the following files: -Starting at line 301 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java -Starting at line 301 of /usr/local/java/src/java/nio/DirectLongBufferS.java - public LongBuffer put(long[] src, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromLongArray(src, offset << 3, - ix(pos), length << 3); - else - Bits.copyFromByteArray(src, offset << 3, - ix(pos), length << 3); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public LongBuffer compact() { -===================================================================== -Found a 32 line (152 tokens) duplication in the following files: -Starting at line 211 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java -Starting at line 211 of /usr/local/java/src/java/nio/DirectLongBufferS.java - public LongBuffer get(long[] dst, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToLongArray(ix(pos), dst, - offset << 3, - length << 3); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 3, - length << 3); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public LongBuffer put(long x) { -===================================================================== -Found a 28 line (152 tokens) duplication in the following files: -Starting at line 301 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 301 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - public DoubleBuffer put(double[] src, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromLongArray(src, offset << 3, - ix(pos), length << 3); - else - Bits.copyFromByteArray(src, offset << 3, - ix(pos), length << 3); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public DoubleBuffer compact() { -===================================================================== -Found a 32 line (152 tokens) duplication in the following files: -Starting at line 211 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 211 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - public DoubleBuffer get(double[] dst, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToLongArray(ix(pos), dst, - offset << 3, - length << 3); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 3, - length << 3); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public DoubleBuffer put(double x) { -===================================================================== -Found a 225 line (152 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectFloatBufferRU.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectFloatBufferRS.java - return new DirectFloatBufferRS(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public FloatBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public FloatBuffer put(float x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer put(int i, float x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer put(FloatBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer put(float[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 28 line (152 tokens) duplication in the following files: -Starting at line 301 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 301 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - public FloatBuffer put(float[] src, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromIntArray(src, offset << 2, - ix(pos), length << 2); - else - Bits.copyFromByteArray(src, offset << 2, - ix(pos), length << 2); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public FloatBuffer compact() { -===================================================================== -Found a 32 line (152 tokens) duplication in the following files: -Starting at line 211 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 211 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - public FloatBuffer get(float[] dst, int offset, int length) { - - if ((length << 2) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToIntArray(ix(pos), dst, - offset << 2, - length << 2); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 2, - length << 2); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public FloatBuffer put(float x) { -===================================================================== -Found a 28 line (152 tokens) duplication in the following files: -Starting at line 301 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 301 of /usr/local/java/src/java/nio/DirectLongBufferU.java - public LongBuffer put(long[] src, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_FROM_ARRAY_THRESHOLD) { - checkBounds(offset, length, src.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferOverflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyFromLongArray(src, offset << 3, - ix(pos), length << 3); - else - Bits.copyFromByteArray(src, offset << 3, - ix(pos), length << 3); - position(pos + length); - } else { - super.put(src, offset, length); - } - return this; - - - - } - - public LongBuffer compact() { -===================================================================== -Found a 32 line (152 tokens) duplication in the following files: -Starting at line 211 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 211 of /usr/local/java/src/java/nio/DirectLongBufferU.java - public LongBuffer get(long[] dst, int offset, int length) { - - if ((length << 3) > Bits.JNI_COPY_TO_ARRAY_THRESHOLD) { - checkBounds(offset, length, dst.length); - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - if (length > rem) - throw new BufferUnderflowException(); - - if (order() != ByteOrder.nativeOrder()) - Bits.copyToLongArray(ix(pos), dst, - offset << 3, - length << 3); - else - Bits.copyToByteArray(ix(pos), dst, - offset << 3, - length << 3); - position(pos + length); - } else { - super.get(dst, offset, length); - } - return this; - - - - } - - - - public LongBuffer put(long x) { -===================================================================== -Found a 225 line (152 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectDoubleBufferRU.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectDoubleBufferRS.java - return new DirectDoubleBufferRS(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public DoubleBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public DoubleBuffer put(double x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer put(int i, double x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer put(DoubleBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer put(double[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 225 line (152 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectLongBufferRU.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectLongBufferRS.java - return new DirectLongBufferRS(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public LongBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public LongBuffer put(long x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer put(int i, long x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer put(LongBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer put(long[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 225 line (152 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectIntBufferRU.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectIntBufferRS.java - return new DirectIntBufferRS(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public IntBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public IntBuffer put(int x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer put(int i, int x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer put(IntBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer put(int[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 229 line (152 tokens) duplication in the following files: -Starting at line 172 of /usr/local/java/src/java/nio/DirectShortBufferRS.java -Starting at line 172 of /usr/local/java/src/java/nio/DirectShortBufferRU.java - return new DirectShortBufferRU(this, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - 0); - } - - public ShortBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ShortBuffer put(short x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer put(int i, short x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer put(ShortBuffer src) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer put(short[] src, int offset, int length) { - - - - - - - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer compact() { - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) -===================================================================== -Found a 125 line (151 tokens) duplication in the following files: -Starting at line 362 of /usr/local/java/src/java/io/PrintStream.java -Starting at line 292 of /usr/local/java/src/java/io/PrintWriter.java - write(c); - } - - /** - * Print an integer. The string produced by {@link - * java.lang.String#valueOf(int)} is translated into bytes according - * to the platform's default character encoding, and these bytes are - * written in exactly the manner of the {@link #write(int)} - * method. - * - * @param i The int to be printed - * @see java.lang.Integer#toString(int) - */ - public void print(int i) { - write(String.valueOf(i)); - } - - /** - * Print a long integer. The string produced by {@link - * java.lang.String#valueOf(long)} is translated into bytes - * according to the platform's default character encoding, and these bytes - * are written in exactly the manner of the {@link #write(int)} - * method. - * - * @param l The long to be printed - * @see java.lang.Long#toString(long) - */ - public void print(long l) { - write(String.valueOf(l)); - } - - /** - * Print a floating-point number. The string produced by {@link - * java.lang.String#valueOf(float)} is translated into bytes - * according to the platform's default character encoding, and these bytes - * are written in exactly the manner of the {@link #write(int)} - * method. - * - * @param f The float to be printed - * @see java.lang.Float#toString(float) - */ - public void print(float f) { - write(String.valueOf(f)); - } - - /** - * Print a double-precision floating-point number. The string produced by - * {@link java.lang.String#valueOf(double)} is translated into - * bytes according to the platform's default character encoding, and these - * bytes are written in exactly the manner of the {@link - * #write(int)} method. - * - * @param d The double to be printed - * @see java.lang.Double#toString(double) - */ - public void print(double d) { - write(String.valueOf(d)); - } - - /** - * Print an array of characters. The characters are converted into bytes - * according to the platform's default character encoding, and these bytes - * are written in exactly the manner of the {@link #write(int)} - * method. - * - * @param s The array of chars to be printed - * - * @throws NullPointerException If s is null - */ - public void print(char s[]) { - write(s); - } - - /** - * Print a string. If the argument is null then the string - * "null" is printed. Otherwise, the string's characters are - * converted into bytes according to the platform's default character - * encoding, and these bytes are written in exactly the manner of the - * {@link #write(int)} method. - * - * @param s The String to be printed - */ - public void print(String s) { - if (s == null) { - s = "null"; - } - write(s); - } - - /** - * Print an object. The string produced by the {@link - * java.lang.String#valueOf(Object)} method is translated into bytes - * according to the platform's default character encoding, and these bytes - * are written in exactly the manner of the {@link #write(int)} - * method. - * - * @param obj The Object to be printed - * @see java.lang.Object#toString() - */ - public void print(Object obj) { - write(String.valueOf(obj)); - } - - - /* Methods that do terminate lines */ - - /** - * Terminate the current line by writing the line separator string. The - * line separator string is defined by the system property - * line.separator, and is not necessarily a single newline - * character ('\n'). - */ - public void println() { - newLine(); - } - - /** - * Print a boolean value and then terminate the line. This method behaves - * as though it invokes {@link #print(boolean)} and then - * {@link #println()}. - * - * @param x the boolean value to be printed - */ - public void println(boolean x) { - synchronized (lock) { -===================================================================== -Found a 23 line (151 tokens) duplication in the following files: -Starting at line 1183 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 1229 of /usr/local/java/src/java/awt/image/DirectColorModel.java - case DataBuffer.TYPE_INT: { - for (int y = 0; y < h; y++, rY++) { - rX = rminX; - for (int x = 0; x < w; x++, rX++) { - pixel = raster.getPixel(rX, rY, pixel); - normAlpha = pixel[aIdx] * alphaScale; - if (normAlpha != 0.f) { - for (int c=0; c < aIdx; c++) { - pixel[c] = (int) (pixel[c] * normAlpha + - 0.5f); - } - raster.setPixel(rX, rY, pixel); - } else { - if (zpixel == null) { - zpixel = new int[numComponents]; - java.util.Arrays.fill(zpixel, 0); - } - raster.setPixel(rX, rY, zpixel); - } - } - } - } - break; -===================================================================== -Found a 45 line (151 tokens) duplication in the following files: -Starting at line 685 of /usr/local/java/src/java/awt/ScrollPane.java -Starting at line 762 of /usr/local/java/src/java/awt/ScrollPane.java -} - -/* - * In JDK 1.1.1, the pkg private class java.awt.PeerFixer was moved to - * become an inner class of ScrollPane, which broke serialization - * for ScrollPane objects using JDK 1.1. - * Instead of moving it back out here, which would break all JDK 1.1.x - * releases, we keep PeerFixer in both places. Because of the scoping rules, - * the PeerFixer that is used in ScrollPane will be the one that is the - * inner class. This pkg private PeerFixer class below will only be used - * if the Java 2 platform is used to deserialize ScrollPane objects that were serialized - * using JDK1.1 - */ -class PeerFixer implements AdjustmentListener, java.io.Serializable { - - PeerFixer(ScrollPane scroller) { - this.scroller = scroller; - } - - /** - * Invoked when the value of the adjustable has changed. - */ - public void adjustmentValueChanged(AdjustmentEvent e) { - Adjustable adj = e.getAdjustable(); - int value = e.getValue(); - ScrollPanePeer peer = (ScrollPanePeer) scroller.peer; - if (peer != null) { - peer.setValue(adj, value); - } - - Component c = scroller.getComponent(0); - switch(adj.getOrientation()) { - case Adjustable.VERTICAL: - c.move(c.getLocation().x, -(value)); - break; - case Adjustable.HORIZONTAL: - c.move(-(value), c.getLocation().y); - break; - default: - throw new IllegalArgumentException("Illegal adjustable orientation"); - } - } - - private ScrollPane scroller; -} -===================================================================== -Found a 82 line (151 tokens) duplication in the following files: -Starting at line 978 of /usr/local/java/src/java/nio/DoubleBuffer.java -Starting at line 978 of /usr/local/java/src/java/nio/ByteBuffer.java -Starting at line 978 of /usr/local/java/src/java/nio/FloatBuffer.java -Starting at line 978 of /usr/local/java/src/java/nio/IntBuffer.java -Starting at line 978 of /usr/local/java/src/java/nio/ShortBuffer.java -Starting at line 978 of /usr/local/java/src/java/nio/LongBuffer.java - public abstract LongBuffer compact(); - - /** - * Tells whether or not this long buffer is direct.

- * - * @return true if, and only if, this buffer is direct - */ - public abstract boolean isDirect(); - - - - /** - * Returns a string summarizing the state of this buffer.

- * - * @return A summary string - */ - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(getClass().getName()); - sb.append("[pos="); - sb.append(position()); - sb.append(" lim="); - sb.append(limit()); - sb.append(" cap="); - sb.append(capacity()); - sb.append("]"); - return sb.toString(); - } - - - - - - - /** - * Returns the current hash code of this buffer. - * - *

The hash code of a long buffer depends only upon its remaining - * elements; that is, upon the elements from position() up to, and - * including, the element at limit() - 1. - * - *

Because buffer hash codes are content-dependent, it is inadvisable - * to use buffers as keys in hash maps or similar data structures unless it - * is known that their contents will not change.

- * - * @return The current hash code of this buffer - */ - public int hashCode() { - int h = 1; - int p = position(); - for (int i = limit() - 1; i >= p; i--) - h = 31 * h + (int)get(i); - return h; - } - - /** - * Tells whether or not this buffer is equal to another object. - * - *

Two long buffers are equal if, and only if, - * - *

    - * - *
  1. They have the same element type,

  2. - * - *
  3. They have the same number of remaining elements, and - *

  4. - * - *
  5. The two sequences of remaining elements, considered - * independently of their starting positions, are pointwise equal. - *

  6. - * - *
- * - *

A long buffer is not equal to any other type of object.

- * - * @param ob The object to which this buffer is to be compared - * - * @return true if, and only if, this buffer is equal to the - * given object - */ - public boolean equals(Object ob) { - if (!(ob instanceof LongBuffer)) -===================================================================== -Found a 38 line (150 tokens) duplication in the following files: -Starting at line 458 of /usr/local/java/src/java/rmi/activation/Activatable.java -Starting at line 229 of /usr/local/java/src/java/rmi/server/UnicastRemoteObject.java - throws java.rmi.NoSuchObjectException - { - return sun.rmi.transport.ObjectTable.unexportObject(obj, force); - } - - /* - * Creates an instance of given server ref type with constructor chosen - * by indicated paramters and supplied with given arguements, and - * export remote object with it. - */ - private static Remote exportObject(Remote obj, String refType, - Class[] params, Object[] args) - throws RemoteException - { - // compose name of server ref class and find it - String refClassName = RemoteRef.packagePrefix + "." + refType; - Class refClass; - try { - refClass = Class.forName(refClassName); - } catch (ClassNotFoundException e) { - throw new ExportException( - "No class found for server ref type: " + refType); - } - - if (!ServerRef.class.isAssignableFrom(refClass)) { - throw new ExportException( - "Server ref class not instance of " + - ServerRef.class.getName() + ": " + refClass.getName()); - } - - // create server ref instance using given constructor and arguments - ServerRef serverRef; - try { - java.lang.reflect.Constructor cons = - refClass.getConstructor(params); - serverRef = (ServerRef) cons.newInstance(args); - // if impl does extends UnicastRemoteObject, set its ref - if (obj instanceof UnicastRemoteObject) -===================================================================== -Found a 32 line (147 tokens) duplication in the following files: -Starting at line 536 of /usr/local/java/src/java/nio/charset/CharsetEncoder.java -Starting at line 536 of /usr/local/java/src/java/nio/charset/CharsetDecoder.java - cr = decodeLoop(in, out); - } catch (BufferUnderflowException x) { - throw new CoderMalfunctionError(x); - } catch (BufferOverflowException x) { - throw new CoderMalfunctionError(x); - } - - if (cr.isOverflow()) - return cr; - - if (cr.isUnderflow()) { - if (endOfInput && in.hasRemaining()) { - cr = CoderResult.malformedForLength(in.remaining()); - // Fall through to malformed-input case - } else { - return cr; - } - } - - CodingErrorAction action = null; - if (cr.isMalformed()) - action = malformedInputAction; - else if (cr.isUnmappable()) - action = unmappableCharacterAction; - else - assert false : cr.toString(); - - if (action == CodingErrorAction.REPORT) - return cr; - - if (action == CodingErrorAction.REPLACE) { - if (out.remaining() < replacement.length()) -===================================================================== -Found a 36 line (146 tokens) duplication in the following files: -Starting at line 453 of /usr/local/java/src/java/awt/TexturePaintContext.java -Starting at line 573 of /usr/local/java/src/java/awt/TexturePaintContext.java - if ((xerr += colincxerr) < 0) { - xerr &= Integer.MAX_VALUE; - x++; - } - if ((x += colincx) >= bWidth) { - x -= bWidth; - } - if ((yerr += colincyerr) < 0) { - yerr &= Integer.MAX_VALUE; - y++; - } - if ((y += colincy) >= bHeight) { - y -= bHeight; - } - } - } - if ((rowxerr += rowincxerr) < 0) { - rowxerr &= Integer.MAX_VALUE; - rowx++; - } - if ((rowx += rowincx) >= bWidth) { - rowx -= bWidth; - } - if ((rowyerr += rowincyerr) < 0) { - rowyerr &= Integer.MAX_VALUE; - rowy++; - } - if ((rowy += rowincy) >= bHeight) { - rowy -= bHeight; - } - out += outSpan; - } - } - } - - static class ByteFilter extends TexturePaintContext { -===================================================================== -Found a 77 line (145 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferL.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferB.java - Bits.putIntB(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public IntBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 77 line (145 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferL.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferB.java - Bits.putLongB(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 77 line (145 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsShortBufferL.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsShortBufferB.java - Bits.putShortB(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public ShortBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 1); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 77 line (145 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferL.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferB.java - Bits.putFloatB(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public FloatBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 80 line (145 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferB.java -Starting at line 112 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferL.java - Bits.putDoubleL(bb, ix(checkIndex(i)), x); - return this; - - - - } - - public DoubleBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; -===================================================================== -Found a 43 line (144 tokens) duplication in the following files: -Starting at line 70 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 70 of /usr/local/java/src/java/security/cert/CertPathValidator.java - private Provider provider; - private String algorithm; - - // for use with the reflection API - private static final Class cl = java.security.Security.class; - private static final Class[] GET_IMPL_PARAMS = { String.class, - String.class, - String.class }; - private static final Class[] GET_IMPL_PARAMS2 = { String.class, - String.class, - Provider.class }; - // Get the implMethod via the name of a provider. Note: the name could - // be null. - private static Method implMethod; - // Get the implMethod2 via a Provider object. - private static Method implMethod2; - private static Boolean implMethod2Set = new Boolean(false); - - static { - implMethod = (Method) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Method m = null; - try { - m = cl.getDeclaredMethod("getImpl", GET_IMPL_PARAMS); - if (m != null) - m.setAccessible(true); - } catch (NoSuchMethodException nsme) { - } - return m; - } - }); - } - - /** - * Creates a CertPathValidator object of the given algorithm, - * and encapsulates the given provider implementation (SPI object) in it. - * - * @param validatorSpi the provider implementation - * @param provider the provider - * @param algorithm the algorithm name - */ - protected CertPathValidator(CertPathValidatorSpi validatorSpi, -===================================================================== -Found a 53 line (143 tokens) duplication in the following files: -Starting at line 474 of /usr/local/java/src/java/util/HashMap.java -Starting at line 470 of /usr/local/java/src/java/util/WeakHashMap.java - } - } - } - - /** - * Copies all of the mappings from the specified map to this map These - * mappings will replace any mappings that this map had for any of the - * keys currently in the specified map.

- * - * @param m mappings to be stored in this map. - * @throws NullPointerException if the specified map is null. - */ - public void putAll(Map m) { - int numKeysToBeAdded = m.size(); - if (numKeysToBeAdded == 0) - return; - - /* - * Expand the map if the map if the number of mappings to be added - * is greater than or equal to threshold. This is conservative; the - * obvious condition is (m.size() + size) >= threshold, but this - * condition could result in a map with twice the appropriate capacity, - * if the keys to be added overlap with the keys already in this map. - * By using the conservative calculation, we subject ourself - * to at most one extra resize. - */ - if (numKeysToBeAdded > threshold) { - int targetCapacity = (int)(numKeysToBeAdded / loadFactor + 1); - if (targetCapacity > MAXIMUM_CAPACITY) - targetCapacity = MAXIMUM_CAPACITY; - int newCapacity = table.length; - while (newCapacity < targetCapacity) - newCapacity <<= 1; - if (newCapacity > table.length) - resize(newCapacity); - } - - for (Iterator i = m.entrySet().iterator(); i.hasNext(); ) { - Map.Entry e = (Map.Entry) i.next(); - put(e.getKey(), e.getValue()); - } - } - - /** - * Removes the mapping for this key from this map if present. - * - * @param key key whose mapping is to be removed from the map. - * @return previous value associated with specified key, or null - * if there was no mapping for key. A null return can - * also indicate that the map previously associated null - * with the specified key. - */ - public Object remove(Object key) { -===================================================================== -Found a 25 line (143 tokens) duplication in the following files: -Starting at line 97 of /usr/local/java/src/java/awt/image/CropImageFilter.java -Starting at line 136 of /usr/local/java/src/java/awt/image/CropImageFilter.java - ColorModel model, int pixels[], int off, - int scansize) { - int x1 = x; - if (x1 < cropX) { - x1 = cropX; - } - int x2 = x + w; - if (x2 > cropX + cropW) { - x2 = cropX + cropW; - } - int y1 = y; - if (y1 < cropY) { - y1 = cropY; - } - int y2 = y + h; - if (y2 > cropY + cropH) { - y2 = cropY + cropH; - } - if (x1 >= x2 || y1 >= y2) { - return; - } - consumer.setPixels(x1 - cropX, y1 - cropY, (x2 - x1), (y2 - y1), - model, pixels, - off + (y1 - y) * scansize + (x1 - x), scansize); - } -===================================================================== -Found a 120 line (142 tokens) duplication in the following files: -Starting at line 406 of /usr/local/java/src/java/awt/MenuItem.java -Starting at line 197 of /usr/local/java/src/java/awt/Button.java - } - - /** - * Sets the command name for the action event fired - * by this button. By default this action command is - * set to match the label of the button. - * @param command A string used to set the button's - * action command. - * If the string is null then the action command - * is set to match the label of the button. - * @see java.awt.event.ActionEvent - * @since JDK1.1 - */ - public void setActionCommand(String command) { - actionCommand = command; - } - - /** - * Returns the command name of the action event fired by this button. - * If the command name is null (default) then this method - * returns the label of the button. - */ - public String getActionCommand() { - return (actionCommand == null? label : actionCommand); - } - - /** - * Adds the specified action listener to receive action events from - * this button. Action events occur when a user presses or releases - * the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so that it no longer - * receives action events from this button. Action events occur - * when a user presses or releases the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this button. - * - * @return all of this button's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event.ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[]) (getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this Button. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * Button b - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this button, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } else { -===================================================================== -Found a 24 line (142 tokens) duplication in the following files: -Starting at line 179 of /usr/local/java/src/java/nio/HeapLongBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapDoubleBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapIntBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapByteBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapFloatBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapShortBuffer.java -Starting at line 179 of /usr/local/java/src/java/nio/HeapCharBuffer.java - HeapCharBuffer sb = (HeapCharBuffer)src; - int n = sb.remaining(); - if (n > remaining()) - throw new BufferOverflowException(); - System.arraycopy(sb.hb, sb.ix(sb.position()), - hb, ix(position()), n); - sb.position(sb.position() + n); - position(position() + n); - } else if (src.isDirect()) { - int n = src.remaining(); - if (n > remaining()) - throw new BufferOverflowException(); - src.get(hb, ix(position()), n); - position(position() + n); - } else { - super.put(src); - } - return this; - - - - } - - public CharBuffer compact() { -===================================================================== -Found a 33 line (141 tokens) duplication in the following files: -Starting at line 4430 of /usr/local/java/src/java/util/regex/Pattern.java -Starting at line 4470 of /usr/local/java/src/java/util/regex/Pattern.java - return ((lhs.match(matcher, i, seq) && rhs.match(matcher, i, seq)) - && next.match(matcher, matcher.last, seq)); - return false; - } - boolean study(TreeInfo info) { - boolean maxV = info.maxValid; - boolean detm = info.deterministic; - - int minL = info.minLength; - int maxL = info.maxLength; - lhs.study(info); - - int minL2 = info.minLength; - int maxL2 = info.maxLength; - - info.minLength = minL; - info.maxLength = maxL; - rhs.study(info); - - info.minLength = Math.min(minL2, info.minLength); - info.maxLength = Math.max(maxL2, info.maxLength); - info.maxValid = maxV; - info.deterministic = detm; - - return next.study(info); - } - } - - /** - * An object added to the tree when a character class has a range - * or single subtracted from it. - */ - static final class Sub extends Add { -===================================================================== -Found a 31 line (141 tokens) duplication in the following files: -Starting at line 3706 of /usr/local/java/src/java/util/regex/Pattern.java -Starting at line 3881 of /usr/local/java/src/java/util/regex/Pattern.java - i = matcher.last; - } - return next.match(matcher, i, seq); - } - boolean study(TreeInfo info) { - // Save original info - int minL = info.minLength; - int maxL = info.maxLength; - boolean maxV = info.maxValid; - boolean detm = info.deterministic; - info.reset(); - - atom.study(info); - - int temp = info.minLength * cmin + minL; - if (temp < minL) { - temp = 0xFFFFFFF; // Arbitrary large number - } - info.minLength = temp; - - if (maxV & info.maxValid) { - temp = info.maxLength * cmax + maxL; - info.maxLength = temp; - if (temp < maxL) { - info.maxValid = false; - } - } else { - info.maxValid = false; - } - - if (info.deterministic && cmin == cmax) { -===================================================================== -Found a 34 line (140 tokens) duplication in the following files: -Starting at line 475 of /usr/local/java/src/java/lang/Throwable.java -Starting at line 523 of /usr/local/java/src/java/lang/Throwable.java - private void printStackTraceAsCause(PrintWriter s, - StackTraceElement[] causedTrace) - { - // assert Thread.holdsLock(s); - - // Compute number of frames in common between this and caused - StackTraceElement[] trace = getOurStackTrace(); - int m = trace.length-1, n = causedTrace.length-1; - while (m >= 0 && n >=0 && trace[m].equals(causedTrace[n])) { - m--; n--; - } - int framesInCommon = trace.length - 1 - m; - - s.println("Caused by: " + this); - for (int i=0; i <= m; i++) - s.println("\tat " + trace[i]); - if (framesInCommon != 0) - s.println("\t... " + framesInCommon + " more"); - - // Recurse if we have a cause - Throwable ourCause = getCause(); - if (ourCause != null) - ourCause.printStackTraceAsCause(s, trace); - } - - /** - * Fills in the execution stack trace. This method records within this - * Throwable object information about the current state of - * the stack frames for the current thread. - * - * @return a reference to this Throwable instance. - * @see java.lang.Throwable#printStackTrace() - */ - public synchronized native Throwable fillInStackTrace(); -===================================================================== -Found a 29 line (140 tokens) duplication in the following files: -Starting at line 678 of /usr/local/java/src/java/util/HashMap.java -Starting at line 655 of /usr/local/java/src/java/util/WeakHashMap.java - return unmaskNull(get()); - } - - public Object getValue() { - return value; - } - - public Object setValue(Object newValue) { - Object oldValue = value; - value = newValue; - return oldValue; - } - - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - Object k1 = getKey(); - Object k2 = e.getKey(); - if (k1 == k2 || (k1 != null && k1.equals(k2))) { - Object v1 = getValue(); - Object v2 = e.getValue(); - if (v1 == v2 || (v1 != null && v1.equals(v2))) - return true; - } - return false; - } - - public int hashCode() { -===================================================================== -Found a 27 line (139 tokens) duplication in the following files: -Starting at line 112 of /usr/local/java/src/java/io/PipedReader.java -Starting at line 132 of /usr/local/java/src/java/io/PipedInputStream.java - protected synchronized void receive(int b) throws IOException { - if (!connected) { - throw new IOException("Pipe not connected"); - } else if (closedByWriter || closedByReader) { - throw new IOException("Pipe closed"); - } else if (readSide != null && !readSide.isAlive()) { - throw new IOException("Read end dead"); - } - - writeSide = Thread.currentThread(); - while (in == out) { - if ((readSide != null) && !readSide.isAlive()) { - throw new IOException("Pipe broken"); - } - /* full: kick any waiting readers */ - notifyAll(); - try { - wait(1000); - } catch (InterruptedException ex) { - throw new java.io.InterruptedIOException(); - } - } - if (in < 0) { - in = 0; - out = 0; - } - buffer[in++] = (byte)(b & 0xFF); -===================================================================== -Found a 24 line (139 tokens) duplication in the following files: -Starting at line 394 of /usr/local/java/src/java/awt/datatransfer/SystemFlavorMap.java -Starting at line 352 of /usr/local/java/src/java/util/Properties.java - return (slashCount % 2 == 1); - } - - /* - * Converts encoded \uxxxx to unicode chars - * and changes special saved chars to their original forms - */ - private String loadConvert(String theString) { - char aChar; - int len = theString.length(); - StringBuffer outBuffer = new StringBuffer(len); - - for (int x=0; x= bWidth) { - x -= bWidth; - } - if ((yerr += colincyerr) < 0) { - yerr &= Integer.MAX_VALUE; - y++; - } - if ((y += colincy) >= bHeight) { - y -= bHeight; - } - } - if ((rowxerr += rowincxerr) < 0) { - rowxerr &= Integer.MAX_VALUE; - rowx++; - } - if ((rowx += rowincx) >= bWidth) { - rowx -= bWidth; - } - if ((rowyerr += rowincyerr) < 0) { - rowyerr &= Integer.MAX_VALUE; - rowy++; - } - if ((rowy += rowincy) >= bHeight) { - rowy -= bHeight; - } -===================================================================== -Found a 29 line (137 tokens) duplication in the following files: -Starting at line 74 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 91 of /usr/local/java/src/java/security/cert/CertificateFactory.java - private static final Class cl = java.security.Security.class; - private static final Class[] GET_IMPL_PARAMS = { String.class, - String.class, - String.class }; - private static final Class[] GET_IMPL_PARAMS2 = { String.class, - String.class, - Provider.class }; - // Get the implMethod via the name of a provider. Note: the name could - // be null. - private static Method implMethod; - // Get the implMethod2 via a Provider object. - private static Method implMethod2; - private static Boolean implMethod2Set = new Boolean(false); - - static { - implMethod = (Method) - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Method m = null; - try { - m = cl.getDeclaredMethod("getImpl", GET_IMPL_PARAMS); - if (m != null) - m.setAccessible(true); - } catch (NoSuchMethodException nsme) { - } - return m; - } - }); - } -===================================================================== -Found a 31 line (137 tokens) duplication in the following files: -Starting at line 454 of /usr/local/java/src/java/awt/image/PixelGrabber.java -Starting at line 539 of /usr/local/java/src/java/awt/image/PixelGrabber.java - int pixels[], int srcOff, int srcScan) { - if (srcY < dstY) { - int diff = dstY - srcY; - if (diff >= srcH) { - return; - } - srcOff += srcScan * diff; - srcY += diff; - srcH -= diff; - } - if (srcY + srcH > dstY + dstH) { - srcH = (dstY + dstH) - srcY; - if (srcH <= 0) { - return; - } - } - if (srcX < dstX) { - int diff = dstX - srcX; - if (diff >= srcW) { - return; - } - srcOff += diff; - srcX += diff; - srcW -= diff; - } - if (srcX + srcW > dstX + dstW) { - srcW = (dstX + dstW) - srcX; - if (srcW <= 0) { - return; - } - } -===================================================================== -Found a 53 line (137 tokens) duplication in the following files: -Starting at line 188 of /usr/local/java/src/java/awt/image/LookupOp.java -Starting at line 396 of /usr/local/java/src/java/awt/image/RescaleOp.java - if (dstNumBands-1 == length || length == 1) { - int minx = dstRaster.getMinX(); - int miny = dstRaster.getMinY(); - int[] bands = new int[numBands-1]; - for (int i=0; i < numBands-1; i++) { - bands[i] = i; - } - dstRaster = - dstRaster.createWritableChild(minx, miny, - dstRaster.getWidth(), - dstRaster.getHeight(), - minx, miny, - bands); - } - } - - // - // Call the raster filter method - // - filter(srcRaster, dstRaster); - - } - - if (needToConvert) { - // ColorModels are not the same - ColorConvertOp ccop = new ColorConvertOp(hints); - ccop.filter(dst, origDst); - } - - return origDst; - } - - /** - * Rescales the pixel data in the source Raster. - * If the destination Raster is null, a new Raster will be created. - * The source and destination must have the same number of bands. - * Otherwise, an IllegalArgumentException is thrown. - * Note that the number of scaling factors/offsets in this object must - * meet the restrictions stated in the class comments above. - * Otherwise, an IllegalArgumentException is thrown. - * @param src the Raster to be filtered - * @param dst the destination for the filtering operation - * or null - * @return the filtered WritableRaster. - * @throws IllegalArgumentException if src and - * dst do not have the same number of bands, - * or if the number of scaling factors and offsets in this - * RescaleOp do not meet the requirements - * stated in the class comments. - */ - public final WritableRaster filter (Raster src, WritableRaster dst) { - int numBands = src.getNumBands(); - int width = src.getWidth(); -===================================================================== -Found a 13 line (131 tokens) duplication in the following files: -Starting at line 1125 of /usr/local/java/src/java/awt/geom/Arc2D.java -Starting at line 1166 of /usr/local/java/src/java/awt/geom/Arc2D.java - if (((x+w) == 0) && ((((getHeight()/2) >= (y-h)) - && ((getHeight()/2) <= y)) - || ((((-1) * (getHeight()/2)) >= (y-h)) - && (((-1) * (getHeight()/2) <= y))))) { - if (containsAngle(Math.PI/2)) { - return true; - } - if (containsAngle(Math.PI*(3/2))) { - return true; - } - } - - yint = Math.abs(Math.sqrt((1-(((x+w)*(x+w)) -===================================================================== -Found a 42 line (130 tokens) duplication in the following files: -Starting at line 907 of /usr/local/java/src/java/io/ObjectOutputStream.java -Starting at line 1153 of /usr/local/java/src/java/io/ObjectInputStream.java - } - - /** - * Verifies that this (possibly subclass) instance can be constructed - * without violating security constraints: the subclass must not override - * security-sensitive non-final methods, or else the - * "enableSubclassImplementation" SerializablePermission is checked. - */ - private void verifySubclass() { - Class cl = getClass(); - synchronized (subclassAudits) { - Boolean result = (Boolean) subclassAudits.get(cl); - if (result == null) { - /* - * Note: only new Boolean instances (i.e., not Boolean.TRUE or - * Boolean.FALSE) must be used as cache values, otherwise cache - * entry will pin associated class. - */ - result = new Boolean(auditSubclass(cl)); - subclassAudits.put(cl, result); - } - if (result.booleanValue()) { - return; - } - } - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); - } - } - - /** - * Performs reflective checks on given subclass to verify that it doesn't - * override security-sensitive non-final methods. Returns true if subclass - * is "safe", false otherwise. - */ - private static boolean auditSubclass(final Class subcl) { - Boolean result = (Boolean) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - for (Class cl = subcl; - cl != ObjectInputStream.class; -===================================================================== -Found a 77 line (130 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferB.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferB.java - public IntBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; - - - - - } - -} -===================================================================== -Found a 77 line (130 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferL.java - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; - - } - -} -===================================================================== -Found a 77 line (130 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferL.java - public IntBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; - - } - -} -===================================================================== -Found a 77 line (130 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferB.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferB.java - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; - - - - - } - -} -===================================================================== -Found a 29 line (129 tokens) duplication in the following files: -Starting at line 2225 of /usr/local/java/src/java/awt/geom/AffineTransform.java -Starting at line 2338 of /usr/local/java/src/java/awt/geom/AffineTransform.java - double[] dstPts, int dstOff, - int numPts) { - double M00, M01, M02, M10, M11, M12; // For caching - if (dstPts == srcPts && - dstOff > srcOff && dstOff < srcOff + numPts * 2) - { - // If the arrays overlap partially with the destination higher - // than the source and we transform the coordinates normally - // we would overwrite some of the later source coordinates - // with results of previous transformations. - // To get around this we use arraycopy to copy the points - // to their final destination with correct overwrite - // handling and then transform them in place in the new - // safer location. - System.arraycopy(srcPts, srcOff, dstPts, dstOff, numPts * 2); - // srcPts = dstPts; // They are known to be equal. - srcOff = dstOff; - } - switch (state) { - default: - stateError(); - /* NOTREACHED */ - case (APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE): - M00 = m00; M01 = m01; M02 = m02; - M10 = m10; M11 = m11; M12 = m12; - while (--numPts >= 0) { - double x = srcPts[srcOff++]; - double y = srcPts[srcOff++]; - dstPts[dstOff++] = M00 * x + M01 * y + M02; -===================================================================== -Found a 4 line (127 tokens) duplication in the following files: -Starting at line 611 of /usr/local/java/src/java/util/BitSet.java -Starting at line 615 of /usr/local/java/src/java/util/BitSet.java - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, -===================================================================== -Found a 16 line (127 tokens) duplication in the following files: -Starting at line 1098 of /usr/local/java/src/java/util/IdentityHashMap.java -Starting at line 935 of /usr/local/java/src/java/util/WeakHashMap.java - } - - public Object[] toArray() { - Collection c = new ArrayList(size()); - for (Iterator i = iterator(); i.hasNext(); ) - c.add(new AbstractMap.SimpleEntry((Map.Entry) i.next())); - return c.toArray(); - } - - public Object[] toArray(Object a[]) { - Collection c = new ArrayList(size()); - for (Iterator i = iterator(); i.hasNext(); ) - c.add(new AbstractMap.SimpleEntry((Map.Entry) i.next())); - return c.toArray(a); - } - } -===================================================================== -Found a 39 line (127 tokens) duplication in the following files: -Starting at line 767 of /usr/local/java/src/java/io/FilePermission.java -Starting at line 1166 of /usr/local/java/src/java/net/SocketPermission.java - private static final ObjectStreamField[] serialPersistentFields = { - new ObjectStreamField("permissions", Vector.class), - }; - - /** - * @serialData "permissions" field (a Vector containing the SocketPermissions). - */ - /* - * Writes the contents of the perms field out as a Vector for - * serialization compatibility with earlier releases. - */ - private void writeObject(ObjectOutputStream out) throws IOException { - // Don't call out.defaultWriteObject() - - // Write out Vector - Vector permissions = new Vector(perms.size()); - permissions.addAll(perms); - - ObjectOutputStream.PutField pfields = out.putFields(); - pfields.put("permissions", permissions); - out.writeFields(); - } - - /* - * Reads in a Vector of SocketPermissions and saves them in the perms field. - */ - private void readObject(ObjectInputStream in) throws IOException, - ClassNotFoundException { - // Don't call in.defaultReadObject() - - // Read in serialized fields - ObjectInputStream.GetField gfields = in.readFields(); - - // Get the one we want - Vector permissions = (Vector)gfields.get("permissions", null); - perms = new ArrayList(permissions.size()); - perms.addAll(permissions); - } -} -===================================================================== -Found a 16 line (127 tokens) duplication in the following files: -Starting at line 1057 of /usr/local/java/src/java/awt/Color.java -Starting at line 1101 of /usr/local/java/src/java/awt/Color.java - public float[] getColorComponents(ColorSpace cspace, float[] compArray) { - if (cs == null) { - cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); - } - float f[]; - if (fvalue == null) { - f = new float[3]; - f[0] = ((float)getRed())/255f; - f[1] = ((float)getGreen())/255f; - f[2] = ((float)getBlue())/255f; - } else { - f = fvalue; - } - float tmp[] = cs.toCIEXYZ(f); - float tmpout[] = cspace.fromCIEXYZ(tmp); - if (compArray == null) { -===================================================================== -Found a 24 line (127 tokens) duplication in the following files: -Starting at line 613 of /usr/local/java/src/java/awt/image/ColorModel.java -Starting at line 680 of /usr/local/java/src/java/awt/image/ColorModel.java -Starting at line 747 of /usr/local/java/src/java/awt/image/ColorModel.java -Starting at line 810 of /usr/local/java/src/java/awt/image/ColorModel.java - public int getAlpha(Object inData) { - int pixel=0,length=0; - switch (transferType) { - case DataBuffer.TYPE_BYTE: - byte bdata[] = (byte[])inData; - pixel = bdata[0] & 0xff; - length = bdata.length; - break; - case DataBuffer.TYPE_USHORT: - short sdata[] = (short[])inData; - pixel = sdata[0] & 0xffff; - length = sdata.length; - break; - case DataBuffer.TYPE_INT: - int idata[] = (int[])inData; - pixel = idata[0]; - length = idata.length; - break; - default: - throw new UnsupportedOperationException("This method has not been "+ - "implemented for transferType " + transferType); - } - if (length == 1) { - return getAlpha(pixel); -===================================================================== -Found a 70 line (127 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferB.java - public FloatBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 70 line (127 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferB.java - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 70 line (127 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferB.java - public IntBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 2); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 73 line (127 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferB.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferL.java - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 3); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; -===================================================================== -Found a 4 line (126 tokens) duplication in the following files: -Starting at line 619 of /usr/local/java/src/java/util/BitSet.java -Starting at line 623 of /usr/local/java/src/java/util/BitSet.java - 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, - 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0}; -===================================================================== -Found a 25 line (125 tokens) duplication in the following files: -Starting at line 180 of /usr/local/java/src/java/util/BitSet.java -Starting at line 295 of /usr/local/java/src/java/util/BitSet.java - public void set(int fromIndex, int toIndex) { - if (fromIndex < 0) - throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex); - if (toIndex < 0) - throw new IndexOutOfBoundsException("toIndex < 0: " + toIndex); - if (fromIndex > toIndex) - throw new IndexOutOfBoundsException("fromIndex: " + fromIndex + - " > toIndex: " + toIndex); - - // Increase capacity if necessary - int endUnitIndex = unitIndex(toIndex); - int unitsRequired = endUnitIndex + 1; - - if (unitsInUse < unitsRequired) { - ensureCapacity(unitsRequired); - unitsInUse = unitsRequired; - } - - int startUnitIndex = unitIndex(fromIndex); - long bitMask = 0; - if (startUnitIndex == endUnitIndex) { - // Case 1: One word - bitMask = (1L << (toIndex & BIT_INDEX_MASK)) - - (1L << (fromIndex & BIT_INDEX_MASK)); - bits[startUnitIndex] |= bitMask; -===================================================================== -Found a 13 line (125 tokens) duplication in the following files: -Starting at line 1210 of /usr/local/java/src/java/awt/geom/Arc2D.java -Starting at line 1253 of /usr/local/java/src/java/awt/geom/Arc2D.java - if (((y-h) == 0) && ((((getWidth()/2) >= x) - && ((getWidth()/2) <= (x+w))) - || ((((-1) * (getWidth()/2)) >= x) - && (((-1) * (getWidth()/2)) <= (x+w))))) { - if (containsAngle(Math.PI)) { - return true; - } - if (containsAngle(Math.PI*2)) { - return true; - } - } - - xint = Math.abs(Math.sqrt((1-(((y-h)*(y-h)) -===================================================================== -Found a 44 line (123 tokens) duplication in the following files: -Starting at line 74 of /usr/local/java/src/java/io/StringBufferInputStream.java -Starting at line 127 of /usr/local/java/src/java/io/ByteArrayInputStream.java - return (pos < count) ? (buf[pos++] & 0xff) : -1; - } - - /** - * Reads up to len bytes of data into an array of bytes - * from this input stream. - * If pos equals count, - * then -1 is returned to indicate - * end of file. Otherwise, the number k - * of bytes read is equal to the smaller of - * len and count-pos. - * If k is positive, then bytes - * buf[pos] through buf[pos+k-1] - * are copied into b[off] through - * b[off+k-1] in the manner performed - * by System.arraycopy. The - * value k is added into pos - * and k is returned. - *

- * This read method cannot block. - * - * @param b the buffer into which the data is read. - * @param off the start offset of the data. - * @param len the maximum number of bytes read. - * @return the total number of bytes read into the buffer, or - * -1 if there is no more data because the end of - * the stream has been reached. - */ - public synchronized int read(byte b[], int off, int len) { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } - if (pos >= count) { - return -1; - } - if (pos + len > count) { - len = count - pos; - } - if (len <= 0) { - return 0; - } -===================================================================== -Found a 54 line (122 tokens) duplication in the following files: -Starting at line 780 of /usr/local/java/src/java/awt/Rectangle.java -Starting at line 205 of /usr/local/java/src/java/awt/geom/Rectangle2D.java - this.height = (float) r.getHeight(); - } - - /** - * Determines where the specified float coordinates lie with respect - * to this Rectangle2D. - * This method computes a binary OR of the appropriate mask values - * indicating, for each side of this Rectangle2D, - * whether or not the specified coordinates are on the same side - * of the edge as the rest of this Rectangle2D. - * @param x, y the specified coordinates - * @return the logical OR of all appropriate out codes. - * @see Rectangle2D#OUT_LEFT - * @see Rectangle2D#OUT_TOP - * @see Rectangle2D#OUT_RIGHT - * @see Rectangle2D#OUT_BOTTOM - * @since 1.2 - */ - public int outcode(double x, double y) { - /* - * Note on casts to double below. If the arithmetic of - * x+w or y+h is done in float, then some bits may be - * lost if the binary exponents of x/y and w/h are not - * similar. By converting to double before the addition - * we force the addition to be carried out in double to - * avoid rounding error in the comparison. - * - * See bug 4320890 for problems that this inaccuracy causes. - */ - int out = 0; - if (this.width <= 0) { - out |= OUT_LEFT | OUT_RIGHT; - } else if (x < this.x) { - out |= OUT_LEFT; - } else if (x > this.x + (double) this.width) { - out |= OUT_RIGHT; - } - if (this.height <= 0) { - out |= OUT_TOP | OUT_BOTTOM; - } else if (y < this.y) { - out |= OUT_TOP; - } else if (y > this.y + (double) this.height) { - out |= OUT_BOTTOM; - } - return out; - } - - /** - * Returns the high precision bounding box of this - * Rectangle2D. - * @return the bounding box of this Rectangle2D. - * @since 1.2 - */ - public Rectangle2D getBounds2D() { -===================================================================== -Found a 17 line (120 tokens) duplication in the following files: -Starting at line 230 of /usr/local/java/src/java/net/SocksSocketImpl.java -Starting at line 454 of /usr/local/java/src/java/net/SocksSocketImpl.java - out.write(addr1); - String userName = (String) java.security.AccessController.doPrivileged( - new sun.security.action.GetPropertyAction("user.name")); - out.write(userName.getBytes()); - out.write(0); - out.flush(); - byte[] data = new byte[8]; - int n = readSocksReply(in, data); - if (n != 8) - throw new SocketException("Reply from SOCKS server has bad length: " + n); - if (data[0] != 0 && data[0] != 4) - throw new SocketException("Reply from SOCKS server has bad version"); - SocketException ex = null; - switch (data[1]) { - case 90: - // Success! - external_address = new InetSocketAddress(baddr, lport); -===================================================================== -Found a 29 line (120 tokens) duplication in the following files: -Starting at line 275 of /usr/local/java/src/java/security/cert/CertificateFactory.java -Starting at line 357 of /usr/local/java/src/java/security/cert/CertStore.java - { - if (provider == null) - throw new IllegalArgumentException("missing provider"); - - if (implMethod2Set.booleanValue() == false) { - synchronized (implMethod2Set) { - if (implMethod2Set.booleanValue() == false) { - implMethod2 = (Method) - AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - Method m = null; - try { - m = cl.getDeclaredMethod("getImpl", - GET_IMPL_PARAMS2); - if (m != null) - m.setAccessible(true); - } catch (NoSuchMethodException nsme) { - } - return m; - } - }); - implMethod2Set = new Boolean(true); - } - } - } - - if (implMethod2 == null) { - throw new NoSuchAlgorithmException(type + " not found"); -===================================================================== -Found a 35 line (120 tokens) duplication in the following files: -Starting at line 824 of /usr/local/java/src/java/util/WeakHashMap.java -Starting at line 872 of /usr/local/java/src/java/util/WeakHashMap.java - } - - public void clear() { - WeakHashMap.this.clear(); - } - - public Object[] toArray() { - Collection c = new ArrayList(size()); - for (Iterator i = iterator(); i.hasNext(); ) - c.add(i.next()); - return c.toArray(); - } - - public Object[] toArray(Object a[]) { - Collection c = new ArrayList(size()); - for (Iterator i = iterator(); i.hasNext(); ) - c.add(i.next()); - return c.toArray(a); - } - } - - /** - * Returns a collection view of the mappings contained in this map. Each - * element in the returned collection is a Map.Entry. The - * collection is backed by the map, so changes to the map are reflected in - * the collection, and vice-versa. The collection supports element - * removal, which removes the corresponding mapping from the map, via the - * Iterator.remove, Collection.remove, - * removeAll, retainAll, and clear operations. - * It does not support the add or addAll operations. - * - * @return a collection view of the mappings contained in this map. - * @see Map.Entry - */ - public Set entrySet() { -===================================================================== -Found a 34 line (119 tokens) duplication in the following files: -Starting at line 234 of /usr/local/java/src/java/security/cert/CertStore.java -Starting at line 395 of /usr/local/java/src/java/security/cert/CertStore.java - provider, - params - } ); - return new CertStore((CertStoreSpi)objs[0], - (Provider)objs[1], type, params); - } catch (IllegalAccessException iae) { - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(type + " not found"); - nsae.initCause(iae); - throw nsae; - } catch (InvocationTargetException ite) { - Throwable t = ite.getCause(); - if (t != null) { - if (t instanceof InvalidAlgorithmParameterException) - throw (InvalidAlgorithmParameterException)t; - if (t instanceof NoSuchAlgorithmException) - throw (NoSuchAlgorithmException)t; - } - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(type + " not found"); - nsae.initCause(ite); - throw nsae; - } - } - - /** - * Returns the parameters used to initialize this CertStore. - * Note that the CertStoreParameters object is cloned before - * it is returned. - * - * @return the parameters used to initialize this CertStore - * (may be null) - */ - public final CertStoreParameters getCertStoreParameters() { -===================================================================== -Found a 8 line (119 tokens) duplication in the following files: -Starting at line 51 of /usr/local/java/src/java/io/Bits.java -Starting at line 62 of /usr/local/java/src/java/io/Bits.java - long j = ((b[off + 7] & 0xFFL) << 0) + - ((b[off + 6] & 0xFFL) << 8) + - ((b[off + 5] & 0xFFL) << 16) + - ((b[off + 4] & 0xFFL) << 24) + - ((b[off + 3] & 0xFFL) << 32) + - ((b[off + 2] & 0xFFL) << 40) + - ((b[off + 1] & 0xFFL) << 48) + - ((b[off + 0] & 0xFFL) << 56); -===================================================================== -Found a 63 line (119 tokens) duplication in the following files: -Starting at line 648 of /usr/local/java/src/java/awt/Choice.java -Starting at line 585 of /usr/local/java/src/java/awt/Checkbox.java - private int checkboxSerializedDataVersion = 1; - - /** - * Writes default serializable fields to stream. Writes - * a list of serializable ItemListeners - * as optional data. The non-serializable - * ItemListeners are detected and - * no attempt is made to serialize them. - * - * @param s the ObjectOutputStream to write - * @serialData null terminated sequence of 0 - * or more pairs; the pair consists of a String - * and an Object; the String indicates - * the type of object and is one of the following: - * itemListenerK indicating an - * ItemListener object - * - * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener) - * @see java.awt.Component#itemListenerK - * @see #readObject(ObjectInputStream) - */ - private void writeObject(ObjectOutputStream s) - throws java.io.IOException - { - s.defaultWriteObject(); - - AWTEventMulticaster.save(s, itemListenerK, itemListener); - s.writeObject(null); - } - - /** - * Reads the ObjectInputStream and if it - * isn't null adds a listener to receive - * item events fired by the Checkbox. - * Unrecognized keys or values will be ignored. - * - * @param s the ObjectInputStream to read - * @exception HeadlessException if - * GraphicsEnvironment.isHeadless returns - * true - * @serial - * @see #removeItemListener(ItemListener) - * @see #addItemListener(ItemListener) - * @see java.awt.GraphicsEnvironment#isHeadless - * @see #writeObject(ObjectOutputStream) - */ - private void readObject(ObjectInputStream s) - throws ClassNotFoundException, IOException, HeadlessException - { - GraphicsEnvironment.checkHeadless(); - s.defaultReadObject(); - - Object keyOrNull; - while(null != (keyOrNull = s.readObject())) { - String key = ((String)keyOrNull).intern(); - - if (itemListenerK == key) - addItemListener((ItemListener)(s.readObject())); - - else // skip value for unrecognized key - s.readObject(); - } - } -===================================================================== -Found a 32 line (119 tokens) duplication in the following files: -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsShortBufferL.java -Starting at line 119 of /usr/local/java/src/java/nio/ByteBufferAsCharBufferB.java - public CharBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - ByteBuffer db = bb.duplicate(); - db.limit(ix(lim)); - db.position(ix(0)); - ByteBuffer sb = db.slice(); - sb.position(pos << 1); - sb.compact(); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return false; - } - - - - public String toString(int start, int end) { -===================================================================== -Found a 57 line (117 tokens) duplication in the following files: -Starting at line 291 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 293 of /usr/local/java/src/java/security/cert/CertPathValidator.java - return new CertPathValidator((CertPathValidatorSpi)objs[0], - (Provider)objs[1], algorithm); - } catch (IllegalAccessException iae) { - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(iae); - throw nsae; - } catch (InvocationTargetException ite) { - Throwable t = ite.getCause(); - if (t != null && t instanceof NoSuchAlgorithmException) - throw (NoSuchAlgorithmException)t; - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(ite); - throw nsae; - } - } - - /** - * Returns the Provider of this - * CertPathValidator. - * - * @return the Provider of this CertPathValidator - */ - public final Provider getProvider() { - return this.provider; - } - - /** - * Returns the algorithm name of this CertPathValidator. - * - * @return the algorithm name of this CertPathValidator - */ - public final String getAlgorithm() { - return this.algorithm; - } - - /** - * Validates the specified certification path using the specified - * algorithm parameter set. - *

- * The CertPath specified must be of a type that is - * supported by the validation algorithm, otherwise an - * InvalidAlgorithmParameterException will be thrown. For - * example, a CertPathValidator that implements the PKIX - * algorithm validates CertPath objects of type X.509. - * - * @param certPath the CertPath to be validated - * @param params the algorithm parameters - * @return the result of the validation algorithm - * @exception CertPathValidatorException if the CertPath - * does not validate - * @exception InvalidAlgorithmParameterException if the specified - * parameters or the type of the specified CertPath are - * inappropriate for this CertPathValidator - */ - public final CertPathValidatorResult validate(CertPath certPath, -===================================================================== -Found a 18 line (117 tokens) duplication in the following files: -Starting at line 1278 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 1296 of /usr/local/java/src/java/awt/image/DirectColorModel.java - case DataBuffer.TYPE_INT: { - for (int y = 0; y < h; y++, rY++) { - rX = rminX; - for (int x = 0; x < w; x++, rX++) { - pixel = raster.getPixel(rX, rY, pixel); - normAlpha = pixel[aIdx] * alphaScale; - if (normAlpha != 0) { - float invAlpha = 1.0f / normAlpha; - for (int c=0; c < aIdx; c++) { - pixel[c] = (int) (pixel[c] * invAlpha + - 0.5f); - } - raster.setPixel(rX, rY, pixel); - } - } - } - } - break; -===================================================================== -Found a 15 line (116 tokens) duplication in the following files: -Starting at line 1514 of /usr/local/java/src/java/awt/image/ComponentColorModel.java -Starting at line 1536 of /usr/local/java/src/java/awt/image/ComponentColorModel.java - 0xffff) / 65535.0f; - if (supportsAlpha) { - alp = (rgb>>24) & 0xff; - if (nBits[1] == 8) { - intpixel[1] = alp; - } else { - intpixel[1] = (int) (alp * (1.0f / 255.0f) * - ((1 << nBits[1]) - 1) + 0.5f); - } - if (isAlphaPremultiplied) { - gray *= (alp * (1.0f / 255.0f)); - } - } - intpixel[0] = (int) (gray * ((1 << nBits[0]) - 1) + 0.5f); - } else { -===================================================================== -Found a 23 line (115 tokens) duplication in the following files: -Starting at line 242 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 244 of /usr/local/java/src/java/security/cert/CertPathValidator.java - public static CertPathValidator getInstance(String algorithm, - Provider provider) - throws NoSuchAlgorithmException - { - if (provider == null) - throw new IllegalArgumentException("missing provider"); - - if (implMethod2Set.booleanValue() == false) { - synchronized (implMethod2Set) { - if (implMethod2Set.booleanValue() == false) { - implMethod2 = (Method) - AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - Method m = null; - try { - m = cl.getDeclaredMethod("getImpl", - GET_IMPL_PARAMS2); - if (m != null) - m.setAccessible(true); - } catch (NoSuchMethodException nsme) { - if (debug != null) - debug.println("CertPathValidator." + -===================================================================== -Found a 97 line (115 tokens) duplication in the following files: -Starting at line 852 of /usr/local/java/src/java/awt/List.java -Starting at line 220 of /usr/local/java/src/java/awt/Button.java - return (actionCommand == null? label : actionCommand); - } - - /** - * Adds the specified action listener to receive action events from - * this button. Action events occur when a user presses or releases - * the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so that it no longer - * receives action events from this button. Action events occur - * when a user presses or releases the mouse over this button. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this button. - * - * @return all of this button's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event.ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[]) (getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this Button. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * Button b - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(b.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this button, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } else { -===================================================================== -Found a 14 line (115 tokens) duplication in the following files: -Starting at line 1152 of /usr/local/java/src/java/awt/geom/Arc2D.java -Starting at line 1195 of /usr/local/java/src/java/awt/geom/Arc2D.java - if (((x+w) < 0) && (((yint >= (y-h)) && (yint <= y)) - || ((((-1) * yint) >= (y-h)) - && (((-1) * yint) <= y)))) { - if (containsAngle((((Math.PI) - intersect_angle)/Math.PI) * 180)) { - return true; - } - if (containsAngle(((Math.PI + intersect_angle)/Math.PI) * 180)) { - return true; - } - } - - } - - if (((y*y)/((getHeight()/2)*(getHeight()/2)) < 1)) { -===================================================================== -Found a 103 line (115 tokens) duplication in the following files: -Starting at line 328 of /usr/local/java/src/java/nio/DirectIntBufferU.java -Starting at line 328 of /usr/local/java/src/java/nio/DirectFloatBufferU.java - public FloatBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 2); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) - ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - -} -===================================================================== -Found a 125 line (115 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferRL.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsFloatBufferRB.java - return new ByteBufferAsFloatBufferRB(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public FloatBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public FloatBuffer put(float x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer put(int i, float x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public FloatBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 103 line (115 tokens) duplication in the following files: -Starting at line 328 of /usr/local/java/src/java/nio/DirectLongBufferU.java -Starting at line 328 of /usr/local/java/src/java/nio/DirectDoubleBufferU.java - public DoubleBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 3); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - - return ((ByteOrder.nativeOrder() != ByteOrder.BIG_ENDIAN) - ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - - } - - - - - - - - - - - - - - - - - - - - - - - - - - -} -===================================================================== -Found a 103 line (115 tokens) duplication in the following files: -Starting at line 328 of /usr/local/java/src/java/nio/DirectIntBufferS.java -Starting at line 328 of /usr/local/java/src/java/nio/DirectFloatBufferS.java - public FloatBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 2); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) - ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - -} -===================================================================== -Found a 103 line (115 tokens) duplication in the following files: -Starting at line 328 of /usr/local/java/src/java/nio/DirectDoubleBufferS.java -Starting at line 328 of /usr/local/java/src/java/nio/DirectLongBufferS.java - public LongBuffer compact() { - - int pos = position(); - int lim = limit(); - assert (pos <= lim); - int rem = (pos <= lim ? lim - pos : 0); - - unsafe.copyMemory(ix(pos), ix(0), rem << 3); - position(rem); - limit(capacity()); - return this; - - - - } - - public boolean isDirect() { - return true; - } - - public boolean isReadOnly() { - return false; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ((ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) - ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); - - - - - - } - - - - - - - - - - - - - - - - - - - - - - - - - - -} -===================================================================== -Found a 125 line (115 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsShortBufferRL.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsShortBufferRB.java - return new ByteBufferAsShortBufferRB(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public ShortBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public ShortBuffer put(short x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer put(int i, short x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public ShortBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 128 line (115 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferRB.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsIntBufferRL.java - return new ByteBufferAsIntBufferRL(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public IntBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public IntBuffer put(int x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer put(int i, int x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public IntBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; -===================================================================== -Found a 128 line (115 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferRB.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsDoubleBufferRL.java - return new ByteBufferAsDoubleBufferRL(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public DoubleBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public DoubleBuffer put(double x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer put(int i, double x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public DoubleBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - - - - return ByteOrder.LITTLE_ENDIAN; -===================================================================== -Found a 125 line (115 tokens) duplication in the following files: -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferRL.java -Starting at line 64 of /usr/local/java/src/java/nio/ByteBufferAsLongBufferRB.java - return new ByteBufferAsLongBufferRB(bb, - this.markValue(), - this.position(), - this.limit(), - this.capacity(), - offset); - } - - public LongBuffer asReadOnlyBuffer() { - - - - - - - - - return duplicate(); - - } - - - - - - - - - - - - - - - - - - public LongBuffer put(long x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer put(int i, long x) { - - - - - throw new ReadOnlyBufferException(); - - } - - public LongBuffer compact() { - - - - - - - - - - - - - - - - - throw new ReadOnlyBufferException(); - - } - - public boolean isDirect() { - return bb.isDirect(); - } - - public boolean isReadOnly() { - return true; - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - public ByteOrder order() { - - return ByteOrder.BIG_ENDIAN; -===================================================================== -Found a 24 line (114 tokens) duplication in the following files: -Starting at line 227 of /usr/local/java/src/java/lang/Short.java -Starting at line 559 of /usr/local/java/src/java/lang/Long.java -Starting at line 874 of /usr/local/java/src/java/lang/Integer.java -Starting at line 228 of /usr/local/java/src/java/lang/Byte.java - Byte result; - - // Handle minus sign, if present - if (nm.startsWith("-")) { - negative = true; - index++; - } - - if (nm.startsWith("0x", index) || nm.startsWith("0X", index)) { - index += 2; - radix = 16; - } else if (nm.startsWith("#", index)) { - index++; - radix = 16; - } else if (nm.startsWith("0", index) && nm.length() > 1 + index) { - index++; - radix = 8; - } - - if (nm.startsWith("-", index)) - throw new NumberFormatException("Negative sign in wrong position"); - - try { - result = Byte.valueOf(nm.substring(index), radix); -===================================================================== -Found a 94 line (114 tokens) duplication in the following files: -Starting at line 853 of /usr/local/java/src/java/awt/List.java -Starting at line 413 of /usr/local/java/src/java/awt/TextField.java - } - - /** - * Adds the specified action listener to receive - * action events from this text field. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so that it no longer - * receives action events from this text field. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this textfield. - * - * @return all of this textfield's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event#ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this TextField. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * TextField t - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(t.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this textfield, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } else { -===================================================================== -Found a 98 line (114 tokens) duplication in the following files: -Starting at line 852 of /usr/local/java/src/java/awt/List.java -Starting at line 430 of /usr/local/java/src/java/awt/MenuItem.java - return (actionCommand == null? label : actionCommand); - } - - /** - * Adds the specified action listener to receive action events - * from this menu item. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so it no longer receives - * action events from this menu item. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this menu item. - * - * @return all of this menu item's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this MenuItem. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * MenuItem m - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this menu item, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } -===================================================================== -Found a 97 line (113 tokens) duplication in the following files: -Starting at line 413 of /usr/local/java/src/java/awt/TextField.java -Starting at line 431 of /usr/local/java/src/java/awt/MenuItem.java - } - - /** - * Adds the specified action listener to receive action events - * from this menu item. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #removeActionListener - * @see #getActionListeners - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void addActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.add(actionListener, l); - newEventsOnly = true; - } - - /** - * Removes the specified action listener so it no longer receives - * action events from this menu item. - * If l is null, no exception is thrown and no action is performed. - * - * @param l the action listener. - * @see #addActionListener - * @see #getActionListeners - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since JDK1.1 - */ - public synchronized void removeActionListener(ActionListener l) { - if (l == null) { - return; - } - actionListener = AWTEventMulticaster.remove(actionListener, l); - } - - /** - * Returns an array of all the action listeners - * registered on this menu item. - * - * @return all of this menu item's ActionListeners - * or an empty array if no action - * listeners are currently registered - * - * @see #addActionListener - * @see #removeActionListener - * @see java.awt.event.ActionEvent - * @see java.awt.event.ActionListener - * @since 1.4 - */ - public synchronized ActionListener[] getActionListeners() { - return (ActionListener[])(getListeners(ActionListener.class)); - } - - /** - * Returns an array of all the objects currently registered - * as FooListeners - * upon this MenuItem. - * FooListeners are registered using the - * addFooListener method. - * - *

- * You can specify the listenerType argument - * with a class literal, such as - * FooListener.class. - * For example, you can query a - * MenuItem m - * for its action listeners with the following code: - * - *

ActionListener[] als = (ActionListener[])(m.getListeners(ActionListener.class));
- * - * If no such listeners exist, this method returns an empty array. - * - * @param listenerType the type of listeners requested; this parameter - * should specify an interface that descends from - * java.util.EventListener - * @return an array of all objects registered as - * FooListeners on this menu item, - * or an empty array if no such - * listeners have been added - * @exception ClassCastException if listenerType - * doesn't specify a class or interface that implements - * java.util.EventListener - * - * @see #getActionListeners - * @since 1.3 - */ - public EventListener[] getListeners(Class listenerType) { - EventListener l = null; - if (listenerType == ActionListener.class) { - l = actionListener; - } -===================================================================== -Found a 44 line (112 tokens) duplication in the following files: -Starting at line 300 of /usr/local/java/src/java/util/zip/Deflater.java -Starting at line 236 of /usr/local/java/src/java/util/zip/Inflater.java - return inflate(b, 0, b.length); - } - - /** - * Returns the ADLER-32 value of the uncompressed data. - * @return the ADLER-32 value of the uncompressed data - */ - public synchronized int getAdler() { - if (strm == 0) { - throw new NullPointerException(); - } - return getAdler(strm); - } - - /** - * Returns the total number of bytes input so far. - * @return the total number of bytes input so far - */ - public synchronized int getTotalIn() { - if (strm == 0) { - throw new NullPointerException(); - } - return getTotalIn(strm); - } - - /** - * Returns the total number of bytes output so far. - * @return the total number of bytes output so far - */ - public synchronized int getTotalOut() { - if (strm == 0) { - throw new NullPointerException(); - } - return getTotalOut(strm); - } - - /** - * Resets inflater so that a new set of input data can be processed. - */ - public synchronized void reset() { - if (strm == 0) { - throw new NullPointerException(); - } - reset(strm); -===================================================================== -Found a 34 line (112 tokens) duplication in the following files: -Starting at line 812 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 484 of /usr/local/java/src/java/awt/image/BandedSampleModel.java - y*scanlineStride + x + bandOffsets[b]); - return sample; - } - - /** - * Returns the samples in a specified band for the specified rectangle - * of pixels in an int array, one sample per data array element. - * ArrayIndexOutOfBoundsException may be thrown if the coordinates are - * not in bounds. - * @param x, y The coordinates of the upper left pixel location - * @param w The width of the pixel rectangle - * @param h The height of the pixel rectangle - * @param b The band to return - * @param iArray If non-null, returns the samples in this array - * @param data The DataBuffer containing the image data - * @return the samples in the specified band for the pixels within - * the specified region. - * @see #setSamples(int, int, int, int, int, int[], DataBuffer) - */ - public int[] getSamples(int x, int y, int w, int h, int b, - int iArray[], DataBuffer data) { - // Bounds check for 'b' will be performed automatically - if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - int samples[]; - if (iArray != null) { - samples = iArray; - } else { - samples = new int [w*h]; - } - - int lineOffset = y*scanlineStride + x + bandOffsets[b]; -===================================================================== -Found a 21 line (111 tokens) duplication in the following files: -Starting at line 335 of /usr/local/java/src/java/net/MulticastSocket.java -Starting at line 381 of /usr/local/java/src/java/net/MulticastSocket.java - public void leaveGroup(SocketAddress mcastaddr, NetworkInterface netIf) - throws IOException { - if (isClosed()) - throw new SocketException("Socket is closed"); - - if (mcastaddr == null || !(mcastaddr instanceof InetSocketAddress)) - throw new IllegalArgumentException("Unsupported address type"); - - if (oldImpl) - throw new UnsupportedOperationException(); - - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkMulticast(((InetSocketAddress)mcastaddr).getAddress()); - } - - if (!((InetSocketAddress)mcastaddr).getAddress().isMulticastAddress()) { - throw new SocketException("Not a multicast address"); - } - - getImpl().leaveGroup(mcastaddr, netIf); -===================================================================== -Found a 14 line (111 tokens) duplication in the following files: -Starting at line 1826 of /usr/local/java/src/java/awt/image/ColorModel.java -Starting at line 1913 of /usr/local/java/src/java/awt/image/ColorModel.java - } - } - short[] tmp = new short[65536]; - for (int i = 0; i <= 65535; i++) { - tmp[i] = (short) i; - } - ICC_Transform[] transformList = new ICC_Transform[2]; - ICC_ColorSpace lgCS = - (ICC_ColorSpace) ColorSpace.getInstance(ColorSpace.CS_GRAY); - transformList[0] = new ICC_Transform ( - lgCS.getProfile(), ICC_Transform.Any, ICC_Transform.In); - transformList[1] = new ICC_Transform ( - grayCS.getProfile(), ICC_Transform.Any, ICC_Transform.Out); - ICC_Transform t = new ICC_Transform(transformList); -===================================================================== -Found a 19 line (111 tokens) duplication in the following files: -Starting at line 1563 of /usr/local/java/src/java/awt/geom/AffineTransform.java -Starting at line 1770 of /usr/local/java/src/java/awt/geom/AffineTransform.java - public void preConcatenate(AffineTransform Tx) { - double M0, M1; - double T00, T01, T10, T11; - double T02, T12; - int mystate = state; - int txstate = Tx.state; - switch ((txstate << HI_SHIFT) | mystate) { - case (HI_IDENTITY | APPLY_IDENTITY): - case (HI_IDENTITY | APPLY_TRANSLATE): - case (HI_IDENTITY | APPLY_SCALE): - case (HI_IDENTITY | APPLY_SCALE | APPLY_TRANSLATE): - case (HI_IDENTITY | APPLY_SHEAR): - case (HI_IDENTITY | APPLY_SHEAR | APPLY_TRANSLATE): - case (HI_IDENTITY | APPLY_SHEAR | APPLY_SCALE): - case (HI_IDENTITY | APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE): - // Tx is IDENTITY... - return; - - case (HI_TRANSLATE | APPLY_IDENTITY): -===================================================================== -Found a 19 line (110 tokens) duplication in the following files: -Starting at line 1993 of /usr/local/java/src/java/lang/String.java -Starting at line 2018 of /usr/local/java/src/java/lang/String.java - upperChar = Character.toUpperCaseEx(ch); - if (upperChar == Character.CHAR_ERROR) { - upperCharArray = Character.toUpperCaseCharArray(ch); - /* Grow result. */ - int mapLen = upperCharArray.length; - char[] result2 = new char[result.length + mapLen - 1]; - System.arraycopy(result, 0, result2, 0, - i + 1 + resultOffset); - for (int x=0; x dx1) { - consumer.setPixels(dx1, dy, dx - dx1, 1, - model, outpix, dx1, destWidth); - } - } - } -===================================================================== -Found a 48 line (110 tokens) duplication in the following files: -Starting at line 313 of /usr/local/java/src/java/nio/channels/DatagramChannel.java -Starting at line 316 of /usr/local/java/src/java/nio/channels/SocketChannel.java - public abstract boolean finishConnect() throws IOException; - - - // -- ByteChannel operations -- - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public abstract int read(ByteBuffer dst) throws IOException; - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public abstract long read(ByteBuffer[] dsts, int offset, int length) - throws IOException; - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public final long read(ByteBuffer[] dsts) throws IOException { - return read(dsts, 0, dsts.length); - } - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public abstract int write(ByteBuffer src) throws IOException; - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public abstract long write(ByteBuffer[] srcs, int offset, int length) - throws IOException; - - /** - * @throws NotYetConnectedException - * If this channel is not yet connected - */ - public final long write(ByteBuffer[] srcs) throws IOException { - return write(srcs, 0, srcs.length); - } - -} -===================================================================== -Found a 12 line (109 tokens) duplication in the following files: -Starting at line 1239 of /usr/local/java/src/java/awt/geom/Arc2D.java -Starting at line 1281 of /usr/local/java/src/java/awt/geom/Arc2D.java - if (((y-h) < 0) && (((xint >= x) && (xint <= (x+w))) - || ((((-1) * xint) >= x) - && (((-1) * xint) <= (x+w))))) { - if (containsAngle(((Math.PI*2) - intersect_angle)/Math.PI * 180)) { - return true; - } - if (containsAngle((Math.PI + intersect_angle)/Math.PI * 180)) { - return true; - } - } - - } -===================================================================== -Found a 28 line (109 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/beans/PropertyChangeSupport.java -Starting at line 337 of /usr/local/java/src/java/beans/VetoableChangeSupport.java - VetoableChangeSupport child = (VetoableChangeSupport)children.get(propertyName); - if (child != null && child.listeners != null) { - return !child.listeners.isEmpty(); - } - } - return false; - } - - /** - * @serialData Null terminated list of VetoableChangeListeners. - *

- * At serialization time we skip non-serializable listeners and - * only serialize the serializable listeners. - * - */ - - private void writeObject(ObjectOutputStream s) throws IOException { - s.defaultWriteObject(); - - java.util.Vector v = null; - synchronized (this) { - if (listeners != null) { - v = (java.util.Vector) listeners.clone(); - } - } - - if (v != null) { - for(int i = 0; i < v.size(); i++) { -===================================================================== -Found a 38 line (108 tokens) duplication in the following files: -Starting at line 205 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 207 of /usr/local/java/src/java/security/cert/CertPathValidator.java - return new CertPathValidator((CertPathValidatorSpi)objs[0], - (Provider)objs[1], algorithm); - } catch (IllegalAccessException iae) { - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(iae); - throw nsae; - } catch (InvocationTargetException ite) { - Throwable t = ite.getTargetException(); - if (t != null) { - if (t instanceof NoSuchProviderException) - throw (NoSuchProviderException)t; - if (t instanceof NoSuchAlgorithmException) - throw (NoSuchAlgorithmException)t; - } - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(ite); - throw nsae; - } - } - - /** - * Returns a CertPathValidator object that implements the - * specified algorithm, as supplied by the specified provider. - * Note: the provider doesn't have to be registered. - * - * @param algorithm the name of the requested - * CertPathValidator algorithm - * @param provider the provider - * @return a CertPathValidator object that implements the - * specified algorithm, as supplied by the specified provider - * @exception NoSuchAlgorithmException if the requested algorithm - * is not available from the specified provider - * @exception IllegalArgumentException if the provider is - * null - */ - public static CertPathValidator getInstance(String algorithm, -===================================================================== -Found a 18 line (107 tokens) duplication in the following files: -Starting at line 1246 of /usr/local/java/src/java/awt/image/ComponentColorModel.java -Starting at line 1554 of /usr/local/java/src/java/awt/image/ComponentColorModel.java - norm[0] = red * factor; - norm[1] = grn * factor; - norm[2] = blu * factor; - norm = colorSpace.fromRGB(norm); - if (nonStdScale) { - for (int i = 0; i < numColorComponents; i++) { - norm[i] = (norm[i] - compOffset[i]) * - compScale[i]; - // REMIND: need to analyze whether this - // clamping is necessary - if (norm[i] < 0.0f) { - norm[i] = 0.0f; - } - if (norm[i] > 1.0f) { - norm[i] = 1.0f; - } - } - } -===================================================================== -Found a 18 line (107 tokens) duplication in the following files: -Starting at line 171 of /usr/local/java/src/java/awt/image/LookupOp.java -Starting at line 379 of /usr/local/java/src/java/awt/image/RescaleOp.java - if (numBands-1 == length || length == 1) { - int minx = srcRaster.getMinX(); - int miny = srcRaster.getMinY(); - int[] bands = new int[numBands-1]; - for (int i=0; i < numBands-1; i++) { - bands[i] = i; - } - srcRaster = - srcRaster.createWritableChild(minx, miny, - srcRaster.getWidth(), - srcRaster.getHeight(), - minx, miny, - bands); - } - } - if (dstCM.hasAlpha()) { - int dstNumBands = dstRaster.getNumBands(); - if (dstNumBands-1 == length || length == 1) { -===================================================================== -Found a 31 line (106 tokens) duplication in the following files: -Starting at line 700 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 439 of /usr/local/java/src/java/awt/image/SinglePixelPackedSampleModel.java - } - return pixels; - } - - /** - * Returns all samples for the specified rectangle of pixels in - * an int array, one sample per array element. - * ArrayIndexOutOfBoundsException may be thrown if the coordinates are - * not in bounds. - * @param x The X coordinate of the upper left pixel location. - * @param y The Y coordinate of the upper left pixel location. - * @param w The width of the pixel rectangle. - * @param h The height of the pixel rectangle. - * @param iArray If non-null, returns the samples in this array. - * @param data The DataBuffer containing the image data. - * @return all samples for the specified region of pixels. - * @see #setPixels(int, int, int, int, int[], DataBuffer) - */ - public int[] getPixels(int x, int y, int w, int h, - int iArray[], DataBuffer data) { - if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - int pixels[]; - if (iArray != null) { - pixels = iArray; - } else { - pixels = new int [w*h*numBands]; - } - int lineOffset = y*scanlineStride + x; -===================================================================== -Found a 17 line (106 tokens) duplication in the following files: -Starting at line 303 of /usr/local/java/src/java/awt/GridLayout.java -Starting at line 352 of /usr/local/java/src/java/awt/GridLayout.java - public Dimension minimumLayoutSize(Container parent) { - synchronized (parent.getTreeLock()) { - Insets insets = parent.getInsets(); - int ncomponents = parent.getComponentCount(); - int nrows = rows; - int ncols = cols; - - if (nrows > 0) { - ncols = (ncomponents + nrows - 1) / nrows; - } else { - nrows = (ncomponents + ncols - 1) / ncols; - } - int w = 0; - int h = 0; - for (int i = 0 ; i < ncomponents ; i++) { - Component comp = parent.getComponent(i); - Dimension d = comp.getMinimumSize(); -===================================================================== -Found a 68 line (106 tokens) duplication in the following files: -Starting at line 332 of /usr/local/java/src/java/nio/channels/DatagramChannel.java -Starting at line 156 of /usr/local/java/src/java/nio/channels/FileChannel.java - public abstract int read(ByteBuffer dst) throws IOException; - - /** - * Reads a sequence of bytes from this channel into a subsequence of the - * given buffers. - * - *

Bytes are read starting at this channel's current file position, and - * then the file position is updated with the number of bytes actually - * read. Otherwise this method behaves exactly as specified in the {@link - * ScatteringByteChannel} interface.

- */ - public abstract long read(ByteBuffer[] dsts, int offset, int length) - throws IOException; - - /** - * Reads a sequence of bytes from this channel into the given buffers. - * - *

Bytes are read starting at this channel's current file position, and - * then the file position is updated with the number of bytes actually - * read. Otherwise this method behaves exactly as specified in the {@link - * ScatteringByteChannel} interface.

- */ - public final long read(ByteBuffer[] dsts) throws IOException { - return read(dsts, 0, dsts.length); - } - - /** - * Writes a sequence of bytes to this channel from the given buffer. - * - *

Bytes are written starting at this channel's current file position - * unless the channel is in append mode, in which case the position is - * first advanced to the end of the file. The file is grown, if necessary, - * to accomodate the written bytes, and then the file position is updated - * with the number of bytes actually written. Otherwise this method - * behaves exactly as specified by the {@link WritableByteChannel} - * interface.

- */ - public abstract int write(ByteBuffer src) throws IOException; - - /** - * Writes a sequence of bytes to this channel from a subsequence of the - * given buffers. - * - *

Bytes are written starting at this channel's current file position - * unless the channel is in append mode, in which case the position is - * first advanced to the end of the file. The file is grown, if necessary, - * to accomodate the written bytes, and then the file position is updated - * with the number of bytes actually written. Otherwise this method - * behaves exactly as specified in the {@link GatheringByteChannel} - * interface.

- */ - public abstract long write(ByteBuffer[] srcs, int offset, int length) - throws IOException; - - /** - * Writes a sequence of bytes to this channel from the given buffers. - * - *

Bytes are written starting at this channel's current file position - * unless the channel is in append mode, in which case the position is - * first advanced to the end of the file. The file is grown, if necessary, - * to accomodate the written bytes, and then the file position is updated - * with the number of bytes actually written. Otherwise this method - * behaves exactly as specified in the {@link GatheringByteChannel} - * interface.

- */ - public final long write(ByteBuffer[] srcs) throws IOException { - return write(srcs, 0, srcs.length); - } -===================================================================== -Found a 16 line (105 tokens) duplication in the following files: -Starting at line 1798 of /usr/local/java/src/java/net/URI.java -Starting at line 1894 of /usr/local/java/src/java/net/URI.java - sb.append(userInfo); - sb.append('@'); - } - boolean needBrackets = ((host.indexOf(':') >= 0) - && !host.startsWith("[") - && !host.endsWith("]")); - if (needBrackets) sb.append('['); - sb.append(host); - if (needBrackets) sb.append(']'); - if (port != -1) { - sb.append(':'); - sb.append(port); - } - } else if (authority != null) { - sb.append("//"); - sb.append(authority); -===================================================================== -Found a 26 line (105 tokens) duplication in the following files: -Starting at line 909 of /usr/local/java/src/java/awt/Container.java -Starting at line 946 of /usr/local/java/src/java/awt/Container.java - synchronized (getTreeLock()) { - int listeners = 0; - switch (id) { - case HierarchyEvent.HIERARCHY_CHANGED: - listeners = listeningChildren; - break; - case HierarchyEvent.ANCESTOR_MOVED: - case HierarchyEvent.ANCESTOR_RESIZED: - if (dbg.on) { - dbg.assertion(changeFlags == 0); - } - listeners = listeningBoundsChildren; - break; - default: - if (dbg.on) { - dbg.assertion(false); - } - break; - } - - if (enabledOnToolkit) { - listeners = descendantsCount; - } - - for (int count = listeners, i = 0; count > 0; i++) { - count -= component[i].createHierarchyEvents(id, this, parent, -===================================================================== -Found a 19 line (105 tokens) duplication in the following files: -Starting at line 124 of /usr/local/java/src/java/awt/geom/ArcIterator.java -Starting at line 193 of /usr/local/java/src/java/awt/geom/ArcIterator.java - coords[1] = y; - if (affine != null) { - affine.transform(coords, 0, coords, 0, 1); - } - return SEG_LINETO; - } - double increment = angExtDeg; - if (increment > 360.0) { - increment = 360.0; - } else if (increment < -360.0) { - increment = -360.0; - } - increment /= arcSegs; - increment = Math.toRadians(increment); - angle += increment * (index - 1); - double relx = Math.cos(angle); - double rely = Math.sin(angle); - double z = btan(increment); - coords[0] = x + (relx - z * rely) * w; -===================================================================== -Found a 32 line (104 tokens) duplication in the following files: -Starting at line 815 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 506 of /usr/local/java/src/java/awt/image/SinglePixelPackedSampleModel.java - } - - /** - * Returns the samples for a specified band for the specified rectangle - * of pixels in an int array, one sample per array element. - * ArrayIndexOutOfBoundsException may be thrown if the coordinates are - * not in bounds. - * @param x The X coordinate of the upper left pixel location. - * @param y The Y coordinate of the upper left pixel location. - * @param w The width of the pixel rectangle. - * @param h The height of the pixel rectangle. - * @param b The band to return. - * @param iArray If non-null, returns the samples in this array. - * @param data The DataBuffer containing the image data. - * @return the samples for the specified band for the specified - * region of pixels. - * @see #setSamples(int, int, int, int, int, int[], DataBuffer) - */ - public int[] getSamples(int x, int y, int w, int h, int b, - int iArray[], DataBuffer data) { - // Bounds check for 'b' will be performed automatically - if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - int samples[]; - if (iArray != null) { - samples = iArray; - } else { - samples = new int [w*h]; - } - int lineOffset = y*scanlineStride + x; -===================================================================== -Found a 27 line (104 tokens) duplication in the following files: -Starting at line 697 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 368 of /usr/local/java/src/java/awt/image/BandedSampleModel.java - for (int i=0; i width) || (y + h > height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - int[] pixels; -===================================================================== -Found a 21 line (103 tokens) duplication in the following files: -Starting at line 359 of /usr/local/java/src/java/lang/CharacterData.java -Starting at line 207 of /usr/local/java/src/java/lang/CharacterDataLatin1.java - } - return directionality; - } - - static boolean isMirrored(char ch) { - return (getProperties(ch) & 0x80000000) != 0; - } - - static char toUpperCaseEx(char ch) { - char mapChar = ch; - int val = getProperties(ch); - - if ((val & 0x00010000) != 0) { - if ((val & 0x07FC0000) != 0x07FC0000) { - int offset = val << 5 >> (5+18); - mapChar = (char)(ch - offset); - } - else { - switch(ch) { - // map overflow characters - case '\u00B5' : mapChar = '\u039C'; break; -===================================================================== -Found a 3 line (103 tokens) duplication in the following files: -Starting at line 197 of /usr/local/java/src/java/util/prefs/Base64.java -Starting at line 211 of /usr/local/java/src/java/util/prefs/Base64.java - private static final byte altBase64ToInt[] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -===================================================================== -Found a 13 line (102 tokens) duplication in the following files: -Starting at line 154 of /usr/local/java/src/java/io/InputStream.java -Starting at line 263 of /usr/local/java/src/java/io/PipedInputStream.java - public synchronized int read(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if ((off < 0) || (off > b.length) || (len < 0) || - ((off + len) > b.length) || ((off + len) < 0)) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - - /* possibly wait on the first character */ - int c = read(); - if (c < 0) { -===================================================================== -Found a 29 line (102 tokens) duplication in the following files: -Starting at line 658 of /usr/local/java/src/java/awt/image/ComponentSampleModel.java -Starting at line 331 of /usr/local/java/src/java/awt/image/BandedSampleModel.java - for (int i=0; i= width) || (y >= height)) { - throw new ArrayIndexOutOfBoundsException - ("Coordinate out of bounds!"); - } - - int[] pixels; -===================================================================== -Found a 20 line (101 tokens) duplication in the following files: -Starting at line 481 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 534 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 587 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 637 of /usr/local/java/src/java/awt/image/DirectColorModel.java -Starting at line 685 of /usr/local/java/src/java/awt/image/DirectColorModel.java - public int getRGB(Object inData) { - int pixel=0; - switch (transferType) { - case DataBuffer.TYPE_BYTE: - byte bdata[] = (byte[])inData; - pixel = bdata[0] & 0xff; - break; - case DataBuffer.TYPE_USHORT: - short sdata[] = (short[])inData; - pixel = sdata[0] & 0xffff; - break; - case DataBuffer.TYPE_INT: - int idata[] = (int[])inData; - pixel = idata[0]; - break; - default: - throw new UnsupportedOperationException("This method has not been "+ - "implemented for transferType " + transferType); - } - return getRGB(pixel); -===================================================================== -Found a 19 line (101 tokens) duplication in the following files: -Starting at line 1014 of /usr/local/java/src/java/awt/image/IndexColorModel.java -Starting at line 963 of /usr/local/java/src/java/awt/image/DirectColorModel.java - switch (transferType) { - case DataBuffer.TYPE_BYTE: - byte bdata[] = (byte[])pixel; - intpixel = bdata[0] & 0xff; - break; - case DataBuffer.TYPE_USHORT: - short sdata[] = (short[])pixel; - intpixel = sdata[0] & 0xffff; - break; - case DataBuffer.TYPE_INT: - int idata[] = (int[])pixel; - intpixel = idata[0]; - break; - default: - throw new UnsupportedOperationException("This method has not been "+ - "implemented for transferType " + transferType); - } - return getComponents(intpixel, components, offset); - } -===================================================================== -Found a 44 line (101 tokens) duplication in the following files: -Starting at line 333 of /usr/local/java/src/java/awt/image/PackedColorModel.java -Starting at line 2874 of /usr/local/java/src/java/awt/image/ComponentColorModel.java - } - - return true; - } - - /** - * Returns a Raster representing the alpha channel of an image, - * extracted from the input Raster. - * This method assumes that Raster objects associated with - * this ColorModel store the alpha band, if present, as - * the last band of image data. Returns null if there is no separate spatial - * alpha channel associated with this ColorModel. - * This method creates a new Raster, but will share the data - * array. - * - * @param raster The WritableRaster from which to extract the - * alpha channel. - * - * @return A WritableRaster containing the image's alpha channel. - * - */ - public WritableRaster getAlphaRaster(WritableRaster raster) { - if (hasAlpha() == false) { - return null; - } - - int x = raster.getMinX(); - int y = raster.getMinY(); - int[] band = new int[1]; - band[0] = raster.getNumBands() - 1; - return raster.createWritableChild(x, y, raster.getWidth(), - raster.getHeight(), x, y, - band); - } - - /** - * Compares this color model with another for equality. - * - * @param obj The object to compare with this color model. - * @return true if the color model objects are equal, - * false if they are not. - */ - public boolean equals(Object obj) { - if (!super.equals(obj)) { -===================================================================== -Found a 5 line (100 tokens) duplication in the following files: -Starting at line 254 of /usr/local/java/src/java/lang/Integer.java -Starting at line 259 of /usr/local/java/src/java/lang/Integer.java - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', -===================================================================== -Found a 26 line (100 tokens) duplication in the following files: -Starting at line 153 of /usr/local/java/src/java/security/cert/CertPathValidator.java -Starting at line 292 of /usr/local/java/src/java/security/cert/CertPathValidator.java - } ); - return new CertPathValidator((CertPathValidatorSpi)objs[0], - (Provider)objs[1], algorithm); - } catch (IllegalAccessException iae) { - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(iae); - throw nsae; - } catch (InvocationTargetException ite) { - Throwable t = ite.getCause(); - if (t != null && t instanceof NoSuchAlgorithmException) - throw (NoSuchAlgorithmException)t; - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(ite); - throw nsae; - } - } - - /** - * Returns the Provider of this - * CertPathValidator. - * - * @return the Provider of this CertPathValidator - */ - public final Provider getProvider() { -===================================================================== -Found a 25 line (100 tokens) duplication in the following files: -Starting at line 153 of /usr/local/java/src/java/security/cert/CertPathBuilder.java -Starting at line 290 of /usr/local/java/src/java/security/cert/CertPathBuilder.java - } ); - return new CertPathBuilder((CertPathBuilderSpi)objs[0], - (Provider)objs[1], algorithm); - } catch (IllegalAccessException iae) { - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(iae); - throw nsae; - } catch (InvocationTargetException ite) { - Throwable t = ite.getCause(); - if (t != null && t instanceof NoSuchAlgorithmException) - throw (NoSuchAlgorithmException)t; - NoSuchAlgorithmException nsae = new - NoSuchAlgorithmException(algorithm + " not found"); - nsae.initCause(ite); - throw nsae; - } - } - - /** - * Returns the provider of this CertPathBuilder. - * - * @return the provider of this CertPathBuilder - */ - public final Provider getProvider() { -===================================================================== -Found a 28 line (100 tokens) duplication in the following files: -Starting at line 350 of /usr/local/java/src/java/awt/Container.java -Starting at line 593 of /usr/local/java/src/java/awt/Container.java - protected void addImpl(Component comp, Object constraints, int index) { - synchronized (getTreeLock()) { - /* Check for correct arguments: index in bounds, - * comp cannot be one of this container's parents, - * and comp cannot be a window. - * comp and container must be on the same GraphicsDevice. - * if comp is container, all sub-components must be on - * same GraphicsDevice. - */ - GraphicsConfiguration thisGC = this.getGraphicsConfiguration(); - - if (index > ncomponents || (index < 0 && index != -1)) { - throw new IllegalArgumentException( - "illegal component position"); - } - if (comp instanceof Container) { - for (Container cn = this; cn != null; cn=cn.parent) { - if (cn == comp) { - throw new IllegalArgumentException( - "adding container's parent to itself"); - } - } - if (comp instanceof Window) { - throw new IllegalArgumentException( - "adding a window to a container"); - } - } - if (thisGC != null) { - diff --git a/src/site/resources/cpp_cpdresults.txt b/src/site/resources/cpp_cpdresults.txt deleted file mode 100644 index 1cf2966fbc..0000000000 --- a/src/site/resources/cpp_cpdresults.txt +++ /dev/null @@ -1,523 +0,0 @@ -===================================================================== -Found a 307 line (984 tokens) duplication in the following files: -Starting at line 1510 of /home/tom/tmp/httpd-2.0/server/mpm/worker/worker.c -Starting at line 1640 of /home/tom/tmp/httpd-2.0/server/mpm/experimental/threadpool/threadpool.c - last_non_dead = i; - ++total_non_dead; - } - } - ap_max_daemons_limit = last_non_dead + 1; - - if (idle_thread_count > max_spare_threads) { - /* Kill off one child */ - ap_mpm_pod_signal(pod, TRUE); - idle_spawn_rate = 1; - } - else if (idle_thread_count < min_spare_threads) { - /* terminate the free list */ - if (free_length == 0) { - /* only report this condition once */ - static int reported = 0; - - if (!reported) { - ap_log_error(APLOG_MARK, APLOG_ERR, 0, - ap_server_conf, - "server reached MaxClients setting, consider" - " raising the MaxClients setting"); - reported = 1; - } - idle_spawn_rate = 1; - } - else { - if (free_length > idle_spawn_rate) { - free_length = idle_spawn_rate; - } - if (idle_spawn_rate >= 8) { - ap_log_error(APLOG_MARK, APLOG_INFO, 0, - ap_server_conf, - "server seems busy, (you may need " - "to increase StartServers, ThreadsPerChild " - "or Min/MaxSpareThreads), " - "spawning %d children, there are around %d idle " - "threads, and %d total children", free_length, - idle_thread_count, total_non_dead); - } - for (i = 0; i < free_length; ++i) { - make_child(ap_server_conf, free_slots[i]); - } - /* the next time around we want to spawn twice as many if this - * wasn't good enough, but not if we've just done a graceful - */ - if (hold_off_on_exponential_spawning) { - --hold_off_on_exponential_spawning; - } - else if (idle_spawn_rate < MAX_SPAWN_RATE) { - idle_spawn_rate *= 2; - } - } - } - else { - idle_spawn_rate = 1; - } -} - -static void server_main_loop(int remaining_children_to_start) -{ - int child_slot; - apr_exit_why_e exitwhy; - int status, processed_status; - apr_proc_t pid; - int i; - - while (!restart_pending && !shutdown_pending) { - ap_wait_or_timeout(&exitwhy, &status, &pid, pconf); - - if (pid.pid != -1) { - processed_status = ap_process_child_status(&pid, exitwhy, status); - if (processed_status == APEXIT_CHILDFATAL) { - shutdown_pending = 1; - child_fatal = 1; - return; - } - /* non-fatal death... note that it's gone in the scoreboard. */ - child_slot = find_child_by_pid(&pid); - if (child_slot >= 0) { - for (i = 0; i < ap_threads_per_child; i++) - ap_update_child_status_from_indexes(child_slot, i, SERVER_DEAD, - (request_rec *) NULL); - - ap_scoreboard_image->parent[child_slot].pid = 0; - ap_scoreboard_image->parent[child_slot].quiescing = 0; - if (processed_status == APEXIT_CHILDSICK) { - /* resource shortage, minimize the fork rate */ - idle_spawn_rate = 1; - } - else if (remaining_children_to_start - && child_slot < ap_daemons_limit) { - /* we're still doing a 1-for-1 replacement of dead - * children with new children - */ - make_child(ap_server_conf, child_slot); - --remaining_children_to_start; - } -#if APR_HAS_OTHER_CHILD - } - else if (apr_proc_other_child_read(&pid, status) == 0) { - /* handled */ -#endif - } - else if (is_graceful) { - /* Great, we've probably just lost a slot in the - * scoreboard. Somehow we don't know about this child. - */ - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, - ap_server_conf, - "long lost child came home! (pid %ld)", - (long)pid.pid); - } - /* Don't perform idle maintenance when a child dies, - * only do it when there's a timeout. Remember only a - * finite number of children can die, and it's pretty - * pathological for a lot to die suddenly. - */ - continue; - } - else if (remaining_children_to_start) { - /* we hit a 1 second timeout in which none of the previous - * generation of children needed to be reaped... so assume - * they're all done, and pick up the slack if any is left. - */ - startup_children(remaining_children_to_start); - remaining_children_to_start = 0; - /* In any event we really shouldn't do the code below because - * few of the servers we just started are in the IDLE state - * yet, so we'd mistakenly create an extra server. - */ - continue; - } - - perform_idle_server_maintenance(); - } -} - -int ap_mpm_run(apr_pool_t *_pconf, apr_pool_t *plog, server_rec *s) -{ - int remaining_children_to_start; - apr_status_t rv; - - ap_log_pid(pconf, ap_pid_fname); - - first_server_limit = server_limit; - first_thread_limit = thread_limit; - if (changed_limit_at_restart) { - ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s, - "WARNING: Attempt to change ServerLimit or ThreadLimit " - "ignored during restart"); - changed_limit_at_restart = 0; - } - - /* Initialize cross-process accept lock */ - ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT, - ap_server_root_relative(_pconf, ap_lock_fname), - ap_my_pid); - - rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname, - ap_accept_lock_mech, _pconf); - if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, - "Couldn't create accept lock"); - return 1; - } - -#if APR_USE_SYSVSEM_SERIALIZE - if (ap_accept_lock_mech == APR_LOCK_DEFAULT || - ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -#else - if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { -#endif - rv = unixd_set_proc_mutex_perms(accept_mutex); - if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s, - "Couldn't set permissions on cross-process lock; " - "check User and Group directives"); - return 1; - } - } - - if (!is_graceful) { - if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { - return 1; - } - /* fix the generation number in the global score; we just got a new, - * cleared scoreboard - */ - ap_scoreboard_image->global->running_generation = ap_my_generation; - } - - set_signals(); - /* Don't thrash... */ - if (max_spare_threads < min_spare_threads + ap_threads_per_child) - max_spare_threads = min_spare_threads + ap_threads_per_child; - - /* If we're doing a graceful_restart then we're going to see a lot - * of children exiting immediately when we get into the main loop - * below (because we just sent them AP_SIG_GRACEFUL). This happens pretty - * rapidly... and for each one that exits we'll start a new one until - * we reach at least daemons_min_free. But we may be permitted to - * start more than that, so we'll just keep track of how many we're - * supposed to start up without the 1 second penalty between each fork. - */ - remaining_children_to_start = ap_daemons_to_start; - if (remaining_children_to_start > ap_daemons_limit) { - remaining_children_to_start = ap_daemons_limit; - } - if (!is_graceful) { - startup_children(remaining_children_to_start); - remaining_children_to_start = 0; - } - else { - /* give the system some time to recover before kicking into - * exponential mode */ - hold_off_on_exponential_spawning = 10; - } - - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, - "%s configured -- resuming normal operations", - ap_get_server_version()); - ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf, - "Server built: %s", ap_get_server_built()); -#ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH - ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf, - "AcceptMutex: %s (default: %s)", - apr_proc_mutex_name(accept_mutex), - apr_proc_mutex_defname()); -#endif - restart_pending = shutdown_pending = 0; - - server_main_loop(remaining_children_to_start); - - if (shutdown_pending) { - /* Time to gracefully shut down: - * Kill child processes, tell them to call child_exit, etc... - * (By "gracefully" we don't mean graceful in the same sense as - * "apachectl graceful" where we allow old connections to finish.) - */ - ap_mpm_pod_killpg(pod, ap_daemons_limit, FALSE); - ap_reclaim_child_processes(1); /* Start with SIGTERM */ - - if (!child_fatal) { - /* cleanup pid file on normal shutdown */ - const char *pidfile = NULL; - pidfile = ap_server_root_relative (pconf, ap_pid_fname); - if ( pidfile != NULL && unlink(pidfile) == 0) - ap_log_error(APLOG_MARK, APLOG_INFO, 0, - ap_server_conf, - "removed PID file %s (pid=%ld)", - pidfile, (long)getpid()); - - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, - ap_server_conf, "caught SIGTERM, shutting down"); - } - return 1; - } - - /* we've been told to restart */ - apr_signal(SIGHUP, SIG_IGN); - - if (one_process) { - /* not worth thinking about */ - return 1; - } - - /* advance to the next generation */ - /* XXX: we really need to make sure this new generation number isn't in - * use by any of the children. - */ - ++ap_my_generation; - ap_scoreboard_image->global->running_generation = ap_my_generation; - - if (is_graceful) { - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, - AP_SIG_GRACEFUL_STRING " received. Doing graceful restart"); - /* wake up the children...time to die. But we'll have more soon */ - ap_mpm_pod_killpg(pod, ap_daemons_limit, TRUE); - - - /* This is mostly for debugging... so that we know what is still - * gracefully dealing with existing request. - */ - - } - else { - /* Kill 'em all. Since the child acts the same on the parents SIGTERM - * and a SIGHUP, we may as well use the same signal, because some user - * pthreads are stealing signals from us left and right. - */ - ap_mpm_pod_killpg(pod, ap_daemons_limit, FALSE); - - ap_reclaim_child_processes(1); /* Start with SIGTERM */ - ap_log_error(APLOG_MARK, APLOG_NOTICE, 0, ap_server_conf, - "SIGHUP received. Attempting to restart"); - } - - return 0; -} - -/* This really should be a post_config hook, but the error log is already - * redirected by that point, so we need to do this in the open_logs phase. - */ -static int worker_open_logs(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) -{ - apr_status_t rv; -===================================================================== -Found a 111 line (491 tokens) duplication in the following files: -Starting at line 424 of /home/tom/tmp/httpd-2.0/server/mpm/prefork/prefork.c -Starting at line 571 of /home/tom/tmp/httpd-2.0/server/mpm/experimental/leader/leader.c - sa.sa_handler = sig_coredump; -#if defined(SA_ONESHOT) - sa.sa_flags = SA_ONESHOT; -#elif defined(SA_RESETHAND) - sa.sa_flags = SA_RESETHAND; -#endif - if (sigaction(SIGSEGV, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGSEGV)"); -#ifdef SIGBUS - if (sigaction(SIGBUS, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGBUS)"); -#endif -#ifdef SIGABORT - if (sigaction(SIGABORT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGABORT)"); -#endif -#ifdef SIGABRT - if (sigaction(SIGABRT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGABRT)"); -#endif -#ifdef SIGILL - if (sigaction(SIGILL, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGILL)"); -#endif - sa.sa_flags = 0; - } - sa.sa_handler = sig_term; - if (sigaction(SIGTERM, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGTERM)"); -#ifdef SIGINT - if (sigaction(SIGINT, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGINT)"); -#endif -#ifdef SIGXCPU - sa.sa_handler = SIG_DFL; - if (sigaction(SIGXCPU, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGXCPU)"); -#endif -#ifdef SIGXFSZ - sa.sa_handler = SIG_DFL; - if (sigaction(SIGXFSZ, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGXFSZ)"); -#endif -#ifdef SIGPIPE - sa.sa_handler = SIG_IGN; - if (sigaction(SIGPIPE, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGPIPE)"); -#endif - - /* we want to ignore HUPs and AP_SIG_GRACEFUL while we're busy - * processing one */ - sigaddset(&sa.sa_mask, SIGHUP); - sigaddset(&sa.sa_mask, AP_SIG_GRACEFUL); - sa.sa_handler = restart; - if (sigaction(SIGHUP, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(SIGHUP)"); - if (sigaction(AP_SIG_GRACEFUL, &sa, NULL) < 0) - ap_log_error(APLOG_MARK, APLOG_WARNING, errno, ap_server_conf, - "sigaction(" AP_SIG_GRACEFUL_STRING ")"); -#else - if (!one_process) { - apr_signal(SIGSEGV, sig_coredump); -#ifdef SIGBUS - apr_signal(SIGBUS, sig_coredump); -#endif /* SIGBUS */ -#ifdef SIGABORT - apr_signal(SIGABORT, sig_coredump); -#endif /* SIGABORT */ -#ifdef SIGABRT - apr_signal(SIGABRT, sig_coredump); -#endif /* SIGABRT */ -#ifdef SIGILL - apr_signal(SIGILL, sig_coredump); -#endif /* SIGILL */ -#ifdef SIGXCPU - apr_signal(SIGXCPU, SIG_DFL); -#endif /* SIGXCPU */ -#ifdef SIGXFSZ - apr_signal(SIGXFSZ, SIG_DFL); -#endif /* SIGXFSZ */ - } - - apr_signal(SIGTERM, sig_term); -#ifdef SIGHUP - apr_signal(SIGHUP, restart); -#endif /* SIGHUP */ -#ifdef AP_SIG_GRACEFUL - apr_signal(AP_SIG_GRACEFUL, restart); -#endif /* AP_SIG_GRACEFUL */ -#ifdef SIGPIPE - apr_signal(SIGPIPE, SIG_IGN); -#endif /* SIGPIPE */ - -#endif -} - -/***************************************************************** - * Here follows a long bunch of generic server bookkeeping stuff... - */ - -===================================================================== -Found a 34 line (170 tokens) duplication in the following files: -Starting at line 114 of /home/tom/tmp/httpd-2.0/server/mpm/experimental/threadpool/pod.c -Starting at line 118 of /home/tom/tmp/httpd-2.0/server/mpm/worker/pod.c - return rv; - } - return rv; -} - -static apr_status_t pod_signal_internal(ap_pod_t *pod, int graceful) -{ - apr_status_t rv; - char char_of_death = graceful ? GRACEFUL_CHAR : RESTART_CHAR; - apr_size_t one = 1; - - do { - rv = apr_file_write(pod->pod_out, &char_of_death, &one); - } while (APR_STATUS_IS_EINTR(rv)); - if (rv != APR_SUCCESS) { - ap_log_error(APLOG_MARK, APLOG_WARNING, rv, ap_server_conf, - "write pipe_of_death"); - } - return rv; -} - -AP_DECLARE(apr_status_t) ap_mpm_pod_signal(ap_pod_t *pod, int graceful) -{ - return pod_signal_internal(pod, graceful); -} - -AP_DECLARE(void) ap_mpm_pod_killpg(ap_pod_t *pod, int num, int graceful) -{ - int i; - apr_status_t rv = APR_SUCCESS; - - for (i = 0; i < num && rv == APR_SUCCESS; i++) { - rv = pod_signal_internal(pod, graceful); - } -===================================================================== -Found a 35 line (111 tokens) duplication in the following files: -Starting at line 1084 of /home/tom/tmp/httpd-2.0/server/request.c -Starting at line 809 of /home/tom/tmp/httpd-2.0/server/request.c - /* If we merged this same section last time, reuse it - */ - if (matches) { - if (last_walk->matched == sec_ent[sec_idx]) { - now_merged = last_walk->merged; - ++last_walk; - --matches; - continue; - } - - /* We fell out of sync. This is our own copy of walked, - * so truncate the remaining matches and reset remaining. - */ - cache->walked->nelts -= matches; - matches = 0; - } - - if (now_merged) { - now_merged = ap_merge_per_dir_configs(r->pool, - now_merged, - sec_ent[sec_idx]); - } - else { - now_merged = sec_ent[sec_idx]; - } - - last_walk = (walk_walked_t*)apr_array_push(cache->walked); - last_walk->matched = sec_ent[sec_idx]; - last_walk->merged = now_merged; - } - - /* If .htaccess files are enabled, check for one, provided we - * have reached a real path. - */ -===================================================================== -Found a 68 line (106 tokens) duplication in the following files: -Starting at line 190 of /home/tom/tmp/httpd-2.0/server/mpm/beos/beos.c -Starting at line 344 of /home/tom/tmp/httpd-2.0/server/mpm/experimental/perchild/perchild.c - -===================================================================== -Found a 10 line (101 tokens) duplication in the following files: -Starting at line 209 of /home/tom/tmp/httpd-2.0/server/util_time.c -Starting at line 263 of /home/tom/tmp/httpd-2.0/server/util_time.c - *date_str++ = ' '; - *date_str++ = xt.tm_hour / 10 + '0'; - *date_str++ = xt.tm_hour % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_min / 10 + '0'; - *date_str++ = xt.tm_min % 10 + '0'; - *date_str++ = ':'; - *date_str++ = xt.tm_sec / 10 + '0'; - *date_str++ = xt.tm_sec % 10 + '0'; - *date_str++ = ' '; - -That took 3706 milliseconds diff --git a/src/site/resources/images/credits/ae-logo.gif b/src/site/resources/images/credits/ae-logo.gif deleted file mode 100644 index 827163e931..0000000000 Binary files a/src/site/resources/images/credits/ae-logo.gif and /dev/null differ diff --git a/src/site/resources/images/credits/atlassian-cenqua-logo.png b/src/site/resources/images/credits/atlassian-cenqua-logo.png deleted file mode 100644 index 01e6130224..0000000000 Binary files a/src/site/resources/images/credits/atlassian-cenqua-logo.png and /dev/null differ diff --git a/src/site/resources/images/credits/bb-pmd.png b/src/site/resources/images/credits/bb-pmd.png deleted file mode 100644 index 4a86b9db3c..0000000000 Binary files a/src/site/resources/images/credits/bb-pmd.png and /dev/null differ diff --git a/src/site/resources/images/credits/cougaar.jpg b/src/site/resources/images/credits/cougaar.jpg deleted file mode 100644 index db5502a75a..0000000000 Binary files a/src/site/resources/images/credits/cougaar.jpg and /dev/null differ diff --git a/src/site/resources/images/credits/darpa.jpg b/src/site/resources/images/credits/darpa.jpg deleted file mode 100644 index b532325288..0000000000 Binary files a/src/site/resources/images/credits/darpa.jpg and /dev/null differ diff --git a/src/site/resources/images/credits/qasystems_logo.jpg b/src/site/resources/images/credits/qasystems_logo.jpg deleted file mode 100644 index 5411199052..0000000000 Binary files a/src/site/resources/images/credits/qasystems_logo.jpg and /dev/null differ diff --git a/src/site/resources/images/credits/refactorit_logo.gif b/src/site/resources/images/credits/refactorit_logo.gif deleted file mode 100644 index d304d7f335..0000000000 Binary files a/src/site/resources/images/credits/refactorit_logo.gif and /dev/null differ diff --git a/src/site/resources/images/credits/yjp.gif b/src/site/resources/images/credits/yjp.gif deleted file mode 100644 index 862d058921..0000000000 Binary files a/src/site/resources/images/credits/yjp.gif and /dev/null differ diff --git a/src/site/resources/images/designer_screenshot.png b/src/site/resources/images/designer_screenshot.png deleted file mode 100644 index 64a59a62d1..0000000000 Binary files a/src/site/resources/images/designer_screenshot.png and /dev/null differ diff --git a/src/site/resources/images/pmd_logo_small.png b/src/site/resources/images/pmd_logo_small.png deleted file mode 100644 index fd0bfb0ad9..0000000000 Binary files a/src/site/resources/images/pmd_logo_small.png and /dev/null differ diff --git a/src/site/resources/images/screenshot_cpd.png b/src/site/resources/images/screenshot_cpd.png deleted file mode 100644 index 349b1d0e48..0000000000 Binary files a/src/site/resources/images/screenshot_cpd.png and /dev/null differ diff --git a/src/site/resources/images/sflogo.png b/src/site/resources/images/sflogo.png deleted file mode 100644 index dbacfdc755..0000000000 Binary files a/src/site/resources/images/sflogo.png and /dev/null differ diff --git a/src/site/site.xml b/src/site/site.xml deleted file mode 100644 index 54fdc53c9b..0000000000 --- a/src/site/site.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - org.apache.maven.skins - maven-fluido-skin - 1.4 - - - - - true - true - - PMD - PMD - images/logo/pmd_logo_tiny.png - index.html - - true - - pmd/pmd - right - black - - - - - - - pmd-logo - images/logo/pmd_logo_small.png - http://pmd.sourceforge.net/ - - - SourceForge - images/sflogo.png - http://sourceforge.net/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/site/xdoc/cgi/start-demo.xml b/src/site/xdoc/cgi/start-demo.xml deleted file mode 100644 index 90152a4245..0000000000 --- a/src/site/xdoc/cgi/start-demo.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - -Running PMD on -<![CDATA[ -<?php - print($unixname) -?> ]]> - - - - -
-

Your PMD Report should be ready in a couple of seconds. It will -be available from here: - -

- -

- -

-

-

-&1"; 
-  print("Executing: " . $cmd);
-  print("
"); - - $fp = popen($cmd, "r" ); - $read = fread( $fp, 4096 ); - - print("
"); - print( $read ); -?> -
-

-
- -