diff -Nru objenesis-1.2/build_eclipse.bat objenesis-1.2+full/build_eclipse.bat --- objenesis-1.2/build_eclipse.bat 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/build_eclipse.bat 2007-02-11 17:07:43.000000000 +0000 @@ -0,0 +1 @@ +%M2_HOME%\bin\mvn.bat eclipse:eclipse -DdownloadSources=true diff -Nru objenesis-1.2/build_release.bat objenesis-1.2+full/build_release.bat --- objenesis-1.2/build_release.bat 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/build_release.bat 2009-06-23 22:20:10.000000000 +0000 @@ -0,0 +1,2 @@ +%M2_HOME%\bin\mvn.bat clean install -Pwebsite,release %* + diff -Nru objenesis-1.2/debian/changelog objenesis-1.2+full/debian/changelog --- objenesis-1.2/debian/changelog 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/changelog 2011-09-18 20:00:33.000000000 +0000 @@ -1,3 +1,14 @@ +objenesis (1.2+full-1) unstable; urgency=low + + * Team upload + * Remove Java runtime from Depends. + * Update Standards-Version: 3.9.2. + * Download full upstream source code from upstream's svn repository. + * Use Maven to build the package. + * Do not build the tck module because of missing dependencies. + + -- Torsten Werner Sun, 18 Sep 2011 21:47:10 +0200 + objenesis (1.2-1) unstable; urgency=low * Initial release. (Closes: #573812) diff -Nru objenesis-1.2/debian/control objenesis-1.2+full/debian/control --- objenesis-1.2/debian/control 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/control 2011-09-18 20:00:33.000000000 +0000 @@ -3,16 +3,18 @@ Priority: optional Maintainer: Debian Java Maintainers Uploaders: Gabriele Giacone <1o5g4r8o@gmail.com> -Build-Depends: debhelper (>= 7.0.50~), javahelper (>= 0.29), maven-repo-helper -Build-Depends-Indep: default-jdk -Standards-Version: 3.8.4 +Build-Depends: debhelper (>= 7), cdbs, default-jdk, maven-debian-helper (>= 1.4) +Build-Depends-Indep: libmaven-javadoc-plugin-java, junit (>= 3.8.2), default-jdk-doc +Standards-Version: 3.9.2 Vcs-Git: git://git.debian.org/pkg-java/objenesis.git Vcs-Browser: http://git.debian.org/?p=pkg-java/objenesis.git Homepage: http://www.objenesis.org/ Package: libobjenesis-java Architecture: all -Depends: default-jre-headless | java2-runtime-headless, ${misc:Depends} +Depends: ${misc:Depends}, ${maven:Depends} +Recommends: ${maven:OptionalDepends} +Suggests: libobjenesis-java-doc Description: Java library to instantiate a new object of a particular class Objenesis is a small Java library that serves one purpose: to instantiate a new object of a particular class. @@ -31,7 +33,8 @@ Package: libobjenesis-java-doc Architecture: all Section: doc -Depends: ${misc:Depends} +Depends: ${misc:Depends}, ${maven:DocDepends} +Recommends: ${maven:DocOptionalDepends} Suggests: libobjenesis-java Description: Documentation for Objenesis Objenesis is a small Java library that serves one purpose: to instantiate a diff -Nru objenesis-1.2/debian/javabuild objenesis-1.2+full/debian/javabuild --- objenesis-1.2/debian/javabuild 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/javabuild 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -objenesis.jar org diff -Nru objenesis-1.2/debian/libobjenesis-java-doc.doc-base.api objenesis-1.2+full/debian/libobjenesis-java-doc.doc-base.api --- objenesis-1.2/debian/libobjenesis-java-doc.doc-base.api 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/libobjenesis-java-doc.doc-base.api 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,10 @@ +Document: libobjenesis-java +Title: API Javadoc for Objenesis parent project +Author: Joe Walnes, Henri Tremblay, Leonardo Mesquita developers +Abstract: This is the API Javadoc provided for the + libobjenesis-java library. +Section: Programming + +Format: HTML +Index: /usr/share/doc/libobjenesis-java/api/index.html +Files: /usr/share/doc/libobjenesis-java/api/* diff -Nru objenesis-1.2/debian/libobjenesis-java-doc.install objenesis-1.2+full/debian/libobjenesis-java-doc.install --- objenesis-1.2/debian/libobjenesis-java-doc.install 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/libobjenesis-java-doc.install 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,2 @@ +target/site/apidocs/* usr/share/doc/libobjenesis-java/api + diff -Nru objenesis-1.2/debian/libobjenesis-java-doc.javadoc objenesis-1.2+full/debian/libobjenesis-java-doc.javadoc --- objenesis-1.2/debian/libobjenesis-java-doc.javadoc 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/libobjenesis-java-doc.javadoc 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -internal diff -Nru objenesis-1.2/debian/libobjenesis-java.poms objenesis-1.2+full/debian/libobjenesis-java.poms --- objenesis-1.2/debian/libobjenesis-java.poms 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/libobjenesis-java.poms 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,27 @@ +# List of POM files for the package +# Format of this file is: +# [option]* +# where option can be: +# --ignore: ignore this POM or +# --no-parent: remove the tag from the POM +# --package=: an alternative package to use when installing this POM +# and its artifact +# --has-package-version: to indicate that the original version of the POM is the same as the upstream part +# of the version for the package. +# --keep-elements=: a list of XML elements to keep in the POM +# during a clean operation with mh_cleanpom or mh_installpom +# --artifact=: path to the build artifact associated with this POM, +# it will be installed when using the command mh_install +# --java-lib: install the jar into /usr/share/java to comply with Debian +# packaging guidelines +# --usj-name=: name to use when installing the library in /usr/share/java +# --usj-version=: version to use when installing the library in /usr/share/java +# --no-usj-versionless: don't install the versionless link in /usr/share/java +# --dest-jar=: the destination for the real jar +# it will be installed with mh_install. +# --classifier=: Optional, the classifier for the jar. Empty by default. +# --ignore-pom: don't install the POM with mh_install or mh_installpoms. To use with POM files that are created +# temporarily for certain artifacts such as Javadoc jars. +# +pom.xml --has-package-version +main/pom.xml --has-package-version diff -Nru objenesis-1.2/debian/maven.cleanIgnoreRules objenesis-1.2+full/debian/maven.cleanIgnoreRules --- objenesis-1.2/debian/maven.cleanIgnoreRules 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/maven.cleanIgnoreRules 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,17 @@ +# Maven clean ignore rules - ignore some Maven dependencies and plugins +# during the clean phase of a Maven build +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., this dependency is then removed +# from the POM before mvn clean is called +# junit junit jar s/3\\..*/3.x/ + diff -Nru objenesis-1.2/debian/maven.ignoreRules objenesis-1.2+full/debian/maven.ignoreRules --- objenesis-1.2/debian/maven.ignoreRules 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/maven.ignoreRules 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,25 @@ +# Maven ignore rules - ignore some Maven dependencies and plugins +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., this dependency is then removed +# from the POM +# junit junit jar s/3\\..*/3.x/ + +com.google.code.maven-license-plugin maven-license-plugin * * * * +com.keyboardsamurais.maven maven-timestamp-plugin * * * * +org.apache.felix maven-bundle-plugin * * * * +org.apache.maven.plugins maven-eclipse-plugin * * * * +org.apache.maven.plugins maven-pmd-plugin * * * * +org.apache.maven.plugins maven-remote-resources-plugin * * * * +org.apache.maven.plugins maven-source-plugin * * * * +org.apache.maven.wagon wagon-ssh-external * * * * +org.codehaus.mojo findbugs-maven-plugin * * * * diff -Nru objenesis-1.2/debian/maven.properties objenesis-1.2+full/debian/maven.properties --- objenesis-1.2/debian/maven.properties 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/maven.properties 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,4 @@ +# Include here properties to pass to Maven during the build. +# For example: +# maven.test.skip=true + diff -Nru objenesis-1.2/debian/maven.publishedRules objenesis-1.2+full/debian/maven.publishedRules --- objenesis-1.2/debian/maven.publishedRules 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/maven.publishedRules 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,19 @@ +# Maven published rules - additional rules to publish, to help +# the packaging work of Debian maintainers using mh_make +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# - a regular expression of the form s/match/replace/ +# in this case, elements that match are transformed using +# the regex rule. +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., replacing the version with 3.x +# junit junit jar s/3\\..*/3.x/ + diff -Nru objenesis-1.2/debian/maven.rules objenesis-1.2+full/debian/maven.rules --- objenesis-1.2/debian/maven.rules 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/maven.rules 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,21 @@ +# Maven rules - transform Maven dependencies and plugins +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# - a regular expression of the form s/match/replace/ +# in this case, elements that match are transformed using +# the regex rule. +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., replacing the version with 3.x +# junit junit jar s/3\\..*/3.x/ + +junit junit jar s/3\..*/3.x/ * * +org.objenesis objenesis-parent pom s/.*/debian/ * * +org.objenesis objenesis jar s/.*/debian/ * * diff -Nru objenesis-1.2/debian/orig-tar.sh objenesis-1.2+full/debian/orig-tar.sh --- objenesis-1.2/debian/orig-tar.sh 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/orig-tar.sh 2011-09-18 20:00:33.000000000 +0000 @@ -4,12 +4,9 @@ PACKAGE=$(dpkg-parsechangelog | sed -n 's/^Source: //p') TARBALL=../${PACKAGE}_${VERSION}.orig.tar.gz DIR=${PACKAGE}-${VERSION} +TAG=$(echo ${VERSION} | sed -e's,\.,_,g') ## objenesis-${VERSION}-bin.zip contains objenesis-${VERSION}-sources.jar -unzip -oj ../objenesis-${VERSION}-bin.zip objenesis-${VERSION}/objenesis-${VERSION}-sources.jar -mkdir $DIR -unzip -d $DIR objenesis-${VERSION}-sources.jar -## download pom from objenesis site and add it to tarball -wget -P $DIR http://objenesis.googlecode.com/svn/trunk/main/pom.xml +svn export http://objenesis.googlecode.com/svn/tags/${TAG} ${DIR} tar -zcvf $TARBALL $DIR -rm -rf $DIR objenesis-1.2-sources.jar ../objenesis-${VERSION}-bin.zip +rm -rf $DIR ../$VERSION diff -Nru objenesis-1.2/debian/patches/0001-do-not-build-the-tck-module.patch objenesis-1.2+full/debian/patches/0001-do-not-build-the-tck-module.patch --- objenesis-1.2/debian/patches/0001-do-not-build-the-tck-module.patch 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/patches/0001-do-not-build-the-tck-module.patch 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1,21 @@ +From: Torsten Werner +Date: Sun, 18 Sep 2011 21:36:17 +0200 +Subject: do not build the tck module + +--- + pom.xml | 1 - + 1 files changed, 0 insertions(+), 1 deletions(-) + +diff --git a/pom.xml b/pom.xml +index e438dce..0985c25 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -27,7 +27,6 @@ limitations under the License. + + + main +- tck + + + +-- diff -Nru objenesis-1.2/debian/patches/series objenesis-1.2+full/debian/patches/series --- objenesis-1.2/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/debian/patches/series 2011-09-18 20:00:33.000000000 +0000 @@ -0,0 +1 @@ +0001-do-not-build-the-tck-module.patch diff -Nru objenesis-1.2/debian/README.source objenesis-1.2+full/debian/README.source --- objenesis-1.2/debian/README.source 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/README.source 2011-09-18 20:00:33.000000000 +0000 @@ -7,3 +7,9 @@ orig.tar.gz used for Debian packaging. For more details on repackaging of upstream sources please see the debian/orig-tar.sh file. + This package was debianized using the mh_make command + from the maven-debian-helper package. + + The build system uses Maven but prevents it from downloading + anything from the Internet, making the build compliant with + the Debian policy. diff -Nru objenesis-1.2/debian/rules objenesis-1.2+full/debian/rules --- objenesis-1.2/debian/rules 2010-03-14 23:19:30.000000000 +0000 +++ objenesis-1.2+full/debian/rules 2011-09-18 20:00:33.000000000 +0000 @@ -1,13 +1,10 @@ #!/usr/bin/make -f -JAVA_HOME=/usr/lib/jvm/default-java +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/maven.mk -%: - dh --with javahelper $@ - -override_dh_auto_install: - mh_installpom -o -v -plibobjenesis-java pom.xml - mh_installjar -plibobjenesis-java -l pom.xml objenesis.jar +JAVA_HOME := /usr/lib/jvm/default-java +DEB_MAVEN_DOC_TARGET := javadoc:jar javadoc:aggregate get-orig-source: uscan --force-download --verbose diff -Nru objenesis-1.2/debian/watch objenesis-1.2+full/debian/watch --- objenesis-1.2/debian/watch 2010-03-14 23:18:25.000000000 +0000 +++ objenesis-1.2+full/debian/watch 2011-09-18 20:00:33.000000000 +0000 @@ -1,3 +1,5 @@ version=3 -http://code.google.com/p/objenesis/downloads/list \ - .*/objenesis-(.*)-bin.zip debian debian/orig-tar.sh + +opts=uversionmangle=s/_/./g \ + http://objenesis.googlecode.com/svn/tags/ (\d.*)/ \ + debian debian/orig-tar.sh diff -Nru objenesis-1.2/header.txt objenesis-1.2+full/header.txt --- objenesis-1.2/header.txt 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/header.txt 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,13 @@ +Copyright ${inceptionYear}-${year} the original author or authors. + +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 -Nru objenesis-1.2/LICENSE.txt objenesis-1.2+full/LICENSE.txt --- objenesis-1.2/LICENSE.txt 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/LICENSE.txt 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,202 @@ + + 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 -Nru objenesis-1.2/main/assembly.xml objenesis-1.2+full/main/assembly.xml --- objenesis-1.2/main/assembly.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/assembly.xml 2009-08-26 22:15:13.000000000 +0000 @@ -0,0 +1,40 @@ + + + bin + + zip + + + + ${project.build.outputDirectory}/META-INF + / + + NOTICE + LICENSE + + + + ${project.build.directory} + / + + *.jar + + + + \ No newline at end of file diff -Nru objenesis-1.2/main/pom.xml objenesis-1.2+full/main/pom.xml --- objenesis-1.2/main/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/pom.xml 2009-08-26 22:15:13.000000000 +0000 @@ -0,0 +1,89 @@ + + + + + + 4.0.0 + + org.objenesis + objenesis-parent + 1.2 + .. + + objenesis + Objenesis + A library for instantiating Java objects + http://objenesis.googlecode.com/svn/docs/index.html + + + + + + + com.keyboardsamurais.maven + maven-timestamp-plugin + + + com.google.code.maven-license-plugin + maven-license-plugin + + + org.apache.maven.plugins + maven-remote-resources-plugin + + + org.apache.felix + maven-bundle-plugin + + + org.objenesis.* + org.objenesis.* + + + + + + + + + + release + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assembly.xml + + + + + make-assembly + package + + single + + + + + + + + + diff -Nru objenesis-1.2/main/.settings/org.eclipse.core.resources.prefs objenesis-1.2+full/main/.settings/org.eclipse.core.resources.prefs --- objenesis-1.2/main/.settings/org.eclipse.core.resources.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/.settings/org.eclipse.core.resources.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,3 @@ +#Sun Feb 11 23:44:27 CET 2007 +eclipse.preferences.version=1 +encoding/=ISO-8859-1 diff -Nru objenesis-1.2/main/.settings/org.eclipse.jdt.core.prefs objenesis-1.2+full/main/.settings/org.eclipse.jdt.core.prefs --- objenesis-1.2/main/.settings/org.eclipse.jdt.core.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/.settings/org.eclipse.jdt.core.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,259 @@ +#Sun Feb 11 23:42:08 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.3 +org.eclipse.jdt.core.compiler.compliance=1.3 +org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines=true +org.eclipse.jdt.core.formatter.comment.format_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=3 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=3 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false diff -Nru objenesis-1.2/main/.settings/org.eclipse.jdt.ui.prefs objenesis-1.2+full/main/.settings/org.eclipse.jdt.ui.prefs --- objenesis-1.2/main/.settings/org.eclipse.jdt.ui.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/.settings/org.eclipse.jdt.ui.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,11 @@ +#Sun Feb 11 23:44:28 CET 2007 +eclipse.preferences.version=1 +formatter_profile=_Objenesis +formatter_settings_version=10 +internal.default.compliance=user +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.javadoc=false +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.text.custom_code_templates= diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/AccessibleInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,34 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.basic; + +/** + * Instantiates a class by grabbing the no-args constructor, making it accessible and then calling + * Constructor.newInstance(). Although this still requires no-arg constructors, it can call + * non-public constructors (if the security manager allows it). + * + * @author Joe Walnes + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class AccessibleInstantiator extends ConstructorInstantiator { + + public AccessibleInstantiator(Class type) { + super(type); + if(constructor != null) { + constructor.setAccessible(true); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ConstructorInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,52 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.basic; + +import java.lang.reflect.Constructor; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by grabbing the no args constructor and calling Constructor.newInstance(). + * This can deal with default public constructors, but that's about it. + * + * @author Joe Walnes + * @see ObjectInstantiator + */ +public class ConstructorInstantiator implements ObjectInstantiator { + + protected Constructor constructor; + + public ConstructorInstantiator(Class type) { + try { + constructor = type.getDeclaredConstructor((Class[]) null); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + + public Object newInstance() { + try { + return constructor.newInstance((Object[]) null); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,45 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.basic; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public + * constructors, but that's about it. + * + * @author Joe Walnes + * @see ObjectInstantiator + */ +public class NewInstanceInstantiator implements ObjectInstantiator { + + private final Class type; + + public NewInstanceInstantiator(Class type) { + this.type = type; + } + + public Object newInstance() { + try { + return type.newInstance(); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,179 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.basic; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.NotSerializableException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamClass; +import java.io.ObjectStreamConstants; +import java.io.Serializable; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by using a dummy input stream that always feeds data for an empty object of + * the same kind. NOTE: This instantiator may not work properly if the class being instantiated + * defines a "readResolve" method, since it may return objects that have been returned previously + * (i.e., there's no guarantee that the returned object is a new one), or even objects from a + * completely different class. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class ObjectInputStreamInstantiator implements ObjectInstantiator { + private static class MockStream extends InputStream { + + private int pointer; + private byte[] data; + private int sequence; + private static final int[] NEXT = new int[] {1, 2, 2}; + private byte[][] buffers; + + private final byte[] FIRST_DATA; + private static byte[] HEADER; + private static byte[] REPEATING_DATA; + + static { + initialize(); + } + + private static void initialize() { + try { + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + DataOutputStream dout = new DataOutputStream(byteOut); + dout.writeShort(ObjectStreamConstants.STREAM_MAGIC); + dout.writeShort(ObjectStreamConstants.STREAM_VERSION); + HEADER = byteOut.toByteArray(); + + byteOut = new ByteArrayOutputStream(); + dout = new DataOutputStream(byteOut); + + dout.writeByte(ObjectStreamConstants.TC_OBJECT); + dout.writeByte(ObjectStreamConstants.TC_REFERENCE); + dout.writeInt(ObjectStreamConstants.baseWireHandle); + REPEATING_DATA = byteOut.toByteArray(); + } + catch(IOException e) { + throw new Error("IOException: " + e.getMessage()); + } + + } + + public MockStream(Class clazz) { + this.pointer = 0; + this.sequence = 0; + this.data = HEADER; + + // (byte) TC_OBJECT + // (byte) TC_CLASSDESC + // (short length) + // (byte * className.length) + // (long)serialVersionUID + // (byte) SC_SERIALIZABLE + // (short)0 + // TC_ENDBLOCKDATA + // TC_NULL + ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); + DataOutputStream dout = new DataOutputStream(byteOut); + try { + dout.writeByte(ObjectStreamConstants.TC_OBJECT); + dout.writeByte(ObjectStreamConstants.TC_CLASSDESC); + dout.writeUTF(clazz.getName()); + dout.writeLong(ObjectStreamClass.lookup(clazz).getSerialVersionUID()); + dout.writeByte(ObjectStreamConstants.SC_SERIALIZABLE); + dout.writeShort((short) 0); // Zero fields + dout.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); + dout.writeByte(ObjectStreamConstants.TC_NULL); + } + catch(IOException e) { + throw new Error("IOException: " + e.getMessage()); + } + this.FIRST_DATA = byteOut.toByteArray(); + buffers = new byte[][] {HEADER, FIRST_DATA, REPEATING_DATA}; + } + + private void advanceBuffer() { + pointer = 0; + sequence = NEXT[sequence]; + data = buffers[sequence]; + } + + public int read() throws IOException { + int result = data[pointer++]; + if(pointer >= data.length) { + advanceBuffer(); + } + + return result; + } + + public int available() throws IOException { + return Integer.MAX_VALUE; + } + + public int read(byte[] b, int off, int len) throws IOException { + int left = len; + int remaining = data.length - pointer; + + while(remaining <= left) { + System.arraycopy(data, pointer, b, off, remaining); + off += remaining; + left -= remaining; + advanceBuffer(); + remaining = data.length - pointer; + } + if(left > 0) { + System.arraycopy(data, pointer, b, off, left); + pointer += left; + } + + return len; + } + } + + private ObjectInputStream inputStream; + + public ObjectInputStreamInstantiator(Class clazz) { + if(Serializable.class.isAssignableFrom(clazz)) { + try { + this.inputStream = new ObjectInputStream(new MockStream(clazz)); + } + catch(IOException e) { + throw new Error("IOException: " + e.getMessage()); + } + } + else { + throw new ObjenesisException(new NotSerializableException(clazz+" not serializable")); + } + } + + public Object newInstance() { + try { + return inputStream.readObject(); + } + catch(ClassNotFoundException e) { + throw new Error("ClassNotFoundException: " + e.getMessage()); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,72 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.basic; + +import java.io.ObjectStreamClass; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by using reflection to make a call to private method + * ObjectStreamClass.newInstance, present in many JVM implementations. This instantiator will create + * classes in a way compatible with serialization, calling the first non-serializable superclass' + * no-arg constructor. + * + * @author Leonardo Mesquita + * @see ObjectInstantiator + * @see java.io.Serializable + */ +public class ObjectStreamClassInstantiator implements ObjectInstantiator { + + private static Method newInstanceMethod; + + private static void initialize() { + if(newInstanceMethod == null) { + try { + newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance", + new Class[] {}); + newInstanceMethod.setAccessible(true); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + } + } + + private final ObjectStreamClass objStreamClass; + + public ObjectStreamClassInstantiator(Class type) { + initialize(); + objStreamClass = ObjectStreamClass.lookup(type); + } + + public Object newInstance() { + + try { + return newInstanceMethod.invoke(objStreamClass, new Object[] {}); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java --- objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,69 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.gcj; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Base class for GCJ-based instantiators. It initializes reflection access to method + * ObjectInputStream.newObject, as well as creating a dummy ObjectInputStream to be used as the + * "this" argument for the method. + * + * @author Leonardo Mesquita + */ +public abstract class GCJInstantiatorBase implements ObjectInstantiator { + protected static Method newObjectMethod = null; + protected static ObjectInputStream dummyStream; + + private static class DummyStream extends ObjectInputStream { + public DummyStream() throws IOException { + } + } + + private static void initialize() { + if(newObjectMethod == null) { + try { + newObjectMethod = ObjectInputStream.class.getDeclaredMethod("newObject", new Class[] { + Class.class, Class.class}); + newObjectMethod.setAccessible(true); + dummyStream = new DummyStream(); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + catch(IOException e) { + throw new ObjenesisException(e); + } + } + } + + protected final Class type; + + public GCJInstantiatorBase(Class type) { + this.type = type; + initialize(); + } + + public abstract Object newInstance(); +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJInstantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,48 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.gcj; + +import java.lang.reflect.InvocationTargetException; + +import org.objenesis.ObjenesisException; + +/** + * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to + * work on GCJ JVMs. This instantiator will not call any constructors. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class GCJInstantiator extends GCJInstantiatorBase { + public GCJInstantiator(Class type) { + super(type); + } + + public Object newInstance() { + try { + return newObjectMethod.invoke(dummyStream, new Object[] {type, Object.class}); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(IllegalAccessException e) { + throw new ObjenesisException(e); + } + catch(InvocationTargetException e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,46 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.gcj; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.SerializationInstantiatorHelper; + +/** + * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to + * work on GCJ JVMs. This instantiator will create classes in a way compatible with serialization, + * calling the first non-serializable superclass' no-arg constructor. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class GCJSerializationInstantiator extends GCJInstantiatorBase { + private Class superType; + + public GCJSerializationInstantiator(Class type) { + super(type); + this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); + } + + public Object newInstance() { + try { + return newObjectMethod.invoke(dummyStream, new Object[] {type, superType}); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,89 @@ +/** + * COPYRIGHT & LICENSE + * + * This code is Copyright (c) 2006 BEA Systems, inc. It is provided free, as-is and without any warranties for the purpose of + * inclusion in Objenesis or any other open source project with a FSF approved license, as long as this notice is not + * removed. There are no limitations on modifying or repackaging the code apart from this. + * + * BEA does not guarantee that the code works, and provides no support for it. Use at your own risk. + * + * Originally developed by Leonardo Mesquita. Copyright notice added by Henrik Ståhl, BEA JRockit Product Manager. + * + */ +package org.objenesis.instantiator.jrockit; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by making a call to internal JRockit private methods. It is only supposed to + * work on JRockit 7.0 JVMs, which are compatible with Java API 1.3.1. This instantiator will not + * call any constructors. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class JRockit131Instantiator implements ObjectInstantiator { + + private Constructor mungedConstructor; + + private static Method newConstructorForSerializationMethod; + + private static void initialize() { + if(newConstructorForSerializationMethod == null) { + Class cl; + try { + cl = Class.forName("COM.jrockit.reflect.MemberAccess"); + newConstructorForSerializationMethod = cl.getDeclaredMethod( + "newConstructorForSerialization", new Class[] {Constructor.class, Class.class}); + newConstructorForSerializationMethod.setAccessible(true); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(ClassNotFoundException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + } + } + + public JRockit131Instantiator(Class type) { + initialize(); + + if(newConstructorForSerializationMethod != null) { + + Constructor javaLangObjectConstructor; + + try { + javaLangObjectConstructor = Object.class.getConstructor((Class[]) null); + } + catch(NoSuchMethodException e) { + throw new Error("Cannot find constructor for java.lang.Object!"); + } + + try { + mungedConstructor = (Constructor) newConstructorForSerializationMethod.invoke(null, + new Object[] {javaLangObjectConstructor, type}); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + + } + + public Object newInstance() { + try { + return mungedConstructor.newInstance((Object[]) null); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,70 @@ +/** + * COPYRIGHT & LICENSE + * + * This code is Copyright (c) 2006 BEA Systems, inc. It is provided free, as-is and without any warranties for the purpose of + * inclusion in Objenesis or any other open source project with a FSF approved license, as long as this notice is not + * removed. There are no limitations on modifying or repackaging the code apart from this. + * + * BEA does not guarantee that the code works, and provides no support for it. Use at your own risk. + * + * Originally developed by Leonardo Mesquita. Copyright notice added by Henrik Ståhl, BEA JRockit Product Manager. + * + */ + +package org.objenesis.instantiator.jrockit; + +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by making a call to internal JRockit private methods. It is only supposed to + * work on JRockit 1.4.2 JVMs prior to release R25.1. From release R25.1 on, JRockit supports + * sun.reflect.ReflectionFactory, making this "trick" unnecessary. This instantiator will not call + * any constructors. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + * @see org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator + */ +public class JRockitLegacyInstantiator implements ObjectInstantiator { + private static Method safeAllocObjectMethod = null; + + private static void initialize() { + if(safeAllocObjectMethod == null) { + Class memSystem; + try { + memSystem = Class.forName("jrockit.vm.MemSystem"); + safeAllocObjectMethod = memSystem.getDeclaredMethod("safeAllocObject", + new Class[] {Class.class}); + safeAllocObjectMethod.setAccessible(true); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(ClassNotFoundException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + } + } + + private final Class type; + + public JRockitLegacyInstantiator(Class type) { + initialize(); + this.type = type; + } + + public Object newInstance() { + try { + return safeAllocObjectMethod.invoke(null, new Object[] {type}); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/NullInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/NullInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/NullInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/NullInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,31 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator; + +/** + * The instantiator that always return a null instance + * + * @author Henri Tremblay + */ +public class NullInstantiator implements ObjectInstantiator { + + /** + * @return Always null + */ + public Object newInstance() { + return null; + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/ObjectInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/ObjectInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/ObjectInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/ObjectInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,33 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator; + +/** + * Instantiates a new object. + * + * @author Leonardo Mesquita + */ +public interface ObjectInstantiator { + + /** + * Returns a new instance of an object. The returned object's class is defined by the + * implementation. + * + * @return A new instance of an object. + */ + Object newInstance(); + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/perc/PercInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/perc/PercInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/perc/PercInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/perc/PercInstantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,63 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.perc; + +import java.io.ObjectInputStream; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by making a call to internal Perc private methods. It is only supposed to + * work on Perc JVMs. This instantiator will not call any constructors. The code was provided by + * Aonix Perc support team. + * + * @author Henri Tremblay + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class PercInstantiator implements ObjectInstantiator { + + private final Method newInstanceMethod; + + private final Object[] typeArgs = new Object[] { null, Boolean.FALSE }; + + public PercInstantiator(Class type) { + + typeArgs[0] = type; + + try { + newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("newInstance", + new Class[] { Class.class, Boolean.TYPE }); + newInstanceMethod.setAccessible(true); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + } + + public Object newInstance() { + try { + return newInstanceMethod.invoke(null, typeArgs); + } catch (Exception e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/perc/PercSerializationInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,96 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.perc; + +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Instantiates a class by making a call to internal Perc private methods. It is only supposed to + * work on Perc JVMs. This instantiator will create classes in a way compatible with serialization, + * calling the first non-serializable superclass' no-arg constructor.

Based on code provided by + * Aonix but doesn't work right now + * + * @author Henri Tremblay + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class PercSerializationInstantiator implements ObjectInstantiator { + + private Object[] typeArgs; + + private final java.lang.reflect.Method newInstanceMethod; + + public PercSerializationInstantiator(Class type) { + + // Find the first unserializable parent class + Class unserializableType = type; + + while(Serializable.class.isAssignableFrom(unserializableType)) { + unserializableType = unserializableType.getSuperclass(); + } + + try { + // Get the special Perc method to call + Class percMethodClass = Class.forName("COM.newmonics.PercClassLoader.Method"); + + newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("noArgConstruct", + new Class[] {Class.class, Object.class, percMethodClass}); + newInstanceMethod.setAccessible(true); + + // Create invoke params + Class percClassClass = Class.forName("COM.newmonics.PercClassLoader.PercClass"); + Method getPercClassMethod = percClassClass.getDeclaredMethod("getPercClass", + new Class[] {Class.class}); + Object someObject = getPercClassMethod.invoke(null, new Object[] {unserializableType}); + Method findMethodMethod = someObject.getClass().getDeclaredMethod("findMethod", + new Class[] {String.class}); + Object percMethod = findMethodMethod.invoke(someObject, new Object[] {"()V"}); + + typeArgs = new Object[] {unserializableType, type, percMethod}; + + } + catch(ClassNotFoundException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + catch(InvocationTargetException e) { + throw new ObjenesisException(e); + } + catch(IllegalAccessException e) { + throw new ObjenesisException(e); + } + } + + public Object newInstance() { + try { + return newInstanceMethod.invoke(null, typeArgs); + } + catch(IllegalAccessException e) { + throw new ObjenesisException(e); + } + catch(InvocationTargetException e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java objenesis-1.2+full/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java --- objenesis-1.2/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/SerializationInstantiatorHelper.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,48 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator; + +import java.io.Serializable; + +/** + * Helper for common serialization-compatible instantiation functions + * + * @author Leonardo Mesquita + */ +public class SerializationInstantiatorHelper { + + /** + * Returns the first non-serializable superclass of a given class. According to Java Object + * Serialization Specification, objects read from a stream are initialized by calling an + * accessible no-arg constructor from the first non-serializable superclass in the object's + * hierarchy, allowing the state of non-serializable fields to be correctly initialized. + * + * @param type Serializable class for which the first non-serializable superclass is to be found + * @return The first non-serializable superclass of 'type'. + * @see java.io.Serializable + */ + public static Class getNonSerializableSuperClass(Class type) { + Class result = type; + while(Serializable.class.isAssignableFrom(result)) { + result = result.getSuperclass(); + if(result == null) { + throw new Error("Bad class hierarchy: No non-serializable parents"); + } + } + return result; + + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java --- objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,58 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.sun; + +import java.io.ObjectInputStream; +import java.lang.reflect.Method; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Base class for Sun 1.3 based instantiators. It initializes reflection access to static method + * ObjectInputStream.allocateNewObject. + * + * @author Leonardo Mesquita + */ +public abstract class Sun13InstantiatorBase implements ObjectInstantiator { + protected static Method allocateNewObjectMethod = null; + + private static void initialize() { + if(allocateNewObjectMethod == null) { + try { + allocateNewObjectMethod = ObjectInputStream.class.getDeclaredMethod( + "allocateNewObject", new Class[] {Class.class, Class.class}); + allocateNewObjectMethod.setAccessible(true); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(NoSuchMethodException e) { + throw new ObjenesisException(e); + } + } + } + + protected final Class type; + + public Sun13InstantiatorBase(Class type) { + this.type = type; + initialize(); + } + + public abstract Object newInstance(); + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13Instantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13Instantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13Instantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13Instantiator.java 2009-06-22 00:01:10.000000000 +0000 @@ -0,0 +1,49 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.sun; + +import java.lang.reflect.InvocationTargetException; + +import org.objenesis.ObjenesisException; + +/** + * Instantiates a class by making a call to internal Sun private methods. It is only supposed to + * work on Sun HotSpot 1.3 JVM. This instantiator will not call any constructors. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class Sun13Instantiator extends Sun13InstantiatorBase { + public Sun13Instantiator(Class type) { + super(type); + } + + public Object newInstance() { + try { + return allocateNewObjectMethod.invoke(null, new Object[] {type, Object.class}); + } + catch(RuntimeException e) { + throw new ObjenesisException(e); + } + catch(IllegalAccessException e) { + throw new ObjenesisException(e); + } + catch(InvocationTargetException e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,46 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.sun; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.SerializationInstantiatorHelper; + +/** + * Instantiates a class by making a call to internal Sun private methods. It is only supposed to + * work on Sun HotSpot 1.3 JVM. This instantiator will create classes in a way compatible with + * serialization, calling the first non-serializable superclass' no-arg constructor. + * + * @author Leonardo Mesquita + * @see org.objenesis.instantiator.ObjectInstantiator + */ +public class Sun13SerializationInstantiator extends Sun13InstantiatorBase { + private final Class superType; + + public Sun13SerializationInstantiator(Class type) { + super(type); + this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); + } + + public Object newInstance() { + try { + return allocateNewObjectMethod.invoke(null, new Object[] {type, superType}); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,62 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.sun; + +import java.lang.reflect.Constructor; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; + +import sun.reflect.ReflectionFactory; + +/** + * Instantiates an object, WITHOUT calling it's constructor, using internal + * sun.reflect.ReflectionFactory - a class only available on JDK's that use Sun's 1.4 (or later) + * Java implementation. This is the best way to instantiate an object without any side effects + * caused by the constructor - however it is not available on every platform. + * + * @author Joe Walnes + * @see ObjectInstantiator + */ +public class SunReflectionFactoryInstantiator implements ObjectInstantiator { + + private final Constructor mungedConstructor; + + public SunReflectionFactoryInstantiator(Class type) { + + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Constructor javaLangObjectConstructor; + + try { + javaLangObjectConstructor = Object.class.getConstructor((Class[]) null); + } + catch(NoSuchMethodException e) { + throw new Error("Cannot find constructor for java.lang.Object!"); + } + mungedConstructor = reflectionFactory.newConstructorForSerialization(type, + javaLangObjectConstructor); + mungedConstructor.setAccessible(true); + } + + public Object newInstance() { + try { + return mungedConstructor.newInstance((Object[]) null); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java --- objenesis-1.2/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,73 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.instantiator.sun; + +import java.io.NotSerializableException; +import java.lang.reflect.Constructor; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; +import org.objenesis.instantiator.SerializationInstantiatorHelper; + +import sun.reflect.ReflectionFactory; + +/** + * Instantiates an object using internal sun.reflect.ReflectionFactory - a class only available on + * JDK's that use Sun's 1.4 (or later) Java implementation. This instantiator will create classes in + * a way compatible with serialization, calling the first non-serializable superclass' no-arg + * constructor. This is the best way to instantiate an object without any side effects caused by the + * constructor - however it is not available on every platform. + * + * @author Leonardo Mesquita + * @see ObjectInstantiator + */ +public class SunReflectionFactorySerializationInstantiator implements ObjectInstantiator { + + private final Constructor mungedConstructor; + + public SunReflectionFactorySerializationInstantiator(Class type) { + + Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); + ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); + Constructor nonSerializableAncestorConstructor; + try { + nonSerializableAncestorConstructor = nonSerializableAncestor + .getConstructor((Class[]) null); + } + catch(NoSuchMethodException e) { + /** + * @todo (Henri) I think we should throw a NotSerializableException just to put the same + * message a ObjectInputStream. Otherwise, the user won't know if the null returned + * if a "Not serializable", a "No default constructor on ancestor" or a "Exception in + * constructor" + */ + throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor")); + } + + mungedConstructor = reflectionFactory.newConstructorForSerialization(type, + nonSerializableAncestorConstructor); + mungedConstructor.setAccessible(true); + } + + public Object newInstance() { + try { + return mungedConstructor.newInstance((Object[]) null); + } + catch(Exception e) { + throw new ObjenesisException(e); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/ObjenesisBase.java objenesis-1.2+full/main/src/org/objenesis/ObjenesisBase.java --- objenesis-1.2/main/src/org/objenesis/ObjenesisBase.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/ObjenesisBase.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,96 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import java.util.HashMap; +import java.util.Map; + +import org.objenesis.instantiator.ObjectInstantiator; +import org.objenesis.strategy.InstantiatorStrategy; + +/** + * Base class to extend if you want to have a class providing your own default strategy. Can also be + * instantiated directly. + * + * @author Henri Tremblay + */ +public class ObjenesisBase implements Objenesis { + + /** Strategy used by this Objenesi implementation to create classes */ + protected final InstantiatorStrategy strategy; + + /** Strategy cache. Key = Class, Value = InstantiatorStrategy */ + protected Map cache; + + /** + * Constructor allowing to pick a strategy and using cache + * + * @param strategy Strategy to use + */ + public ObjenesisBase(InstantiatorStrategy strategy) { + this(strategy, true); + } + + /** + * Flexible constructor allowing to pick the strategy and if caching should be used + * + * @param strategy Strategy to use + * @param useCache If {@link ObjectInstantiator}s should be cached + */ + public ObjenesisBase(InstantiatorStrategy strategy, boolean useCache) { + if(strategy == null) { + throw new IllegalArgumentException("A strategy can't be null"); + } + this.strategy = strategy; + this.cache = useCache ? new HashMap() : null; + } + + public String toString() { + return getClass().getName() + " using " + strategy.getClass().getName() + + (cache == null ? " without" : " with") + " caching"; + } + + /** + * Will create a new object without any constructor being called + * + * @param clazz Class to instantiate + * @return New instance of clazz + */ + public Object newInstance(Class clazz) { + return getInstantiatorOf(clazz).newInstance(); + } + + /** + * Will pick the best instantiator for the provided class. If you need to create a lot of + * instances from the same class, it is way more efficient to create them from the same + * ObjectInstantiator than calling {@link #newInstance(Class)}. + * + * @param clazz Class to instantiate + * @return Instantiator dedicated to the class + */ + public synchronized ObjectInstantiator getInstantiatorOf(Class clazz) { + if(cache == null) { + return strategy.newInstantiatorOf(clazz); + } + ObjectInstantiator instantiator = (ObjectInstantiator) cache.get(clazz.getName()); + if(instantiator == null) { + instantiator = strategy.newInstantiatorOf(clazz); + cache.put(clazz.getName(), instantiator); + } + return instantiator; + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/ObjenesisException.java objenesis-1.2+full/main/src/org/objenesis/ObjenesisException.java --- objenesis-1.2/main/src/org/objenesis/ObjenesisException.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/ObjenesisException.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,59 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +/** + * Exception thrown by Objenesis. It wraps any instantiation exceptions. Note that this exception is + * runtime to prevent having to catch it. It will do normal exception wrapping for JDK 1.4 and more + * and basic message wrapping for JDK 1.3. + * + * @author Henri Tremblay + */ +public class ObjenesisException extends RuntimeException { + + private static final long serialVersionUID = -2677230016262426968L; + + private static final boolean jdk14 = (Double.parseDouble(System + .getProperty("java.specification.version")) > 1.3); + + /** + * @param msg Error message + */ + public ObjenesisException(String msg) { + super(msg); + } + + /** + * @param cause Wrapped exception. The message will be the one of the cause. + */ + public ObjenesisException(Throwable cause) { + super(cause == null ? null : cause.toString()); + if(jdk14) { + initCause(cause); + } + } + + /** + * @param msg Error message + * @param cause Wrapped exception + */ + public ObjenesisException(String msg, Throwable cause) { + super(msg); + if(jdk14) { + initCause(cause); + } + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/ObjenesisHelper.java objenesis-1.2+full/main/src/org/objenesis/ObjenesisHelper.java --- objenesis-1.2/main/src/org/objenesis/ObjenesisHelper.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/ObjenesisHelper.java 2009-06-21 23:59:22.000000000 +0000 @@ -0,0 +1,80 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import java.io.Serializable; + +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Use Objenesis in a static way. It is strongly not recommended to use this class. + * + * @author Henri Tremblay + */ +public final class ObjenesisHelper { + + private static final Objenesis OBJENESIS_STD = new ObjenesisStd(); + + private static final Objenesis OBJENESIS_SERIALIZER = new ObjenesisSerializer(); + + private ObjenesisHelper() { + } + + /** + * Will create a new object without any constructor being called + * + * @param clazz Class to instantiate + * @return New instance of clazz + */ + public static Object newInstance(Class clazz) { + return OBJENESIS_STD.newInstance(clazz); + } + + /** + * Will create an object just like it's done by ObjectInputStream.readObject (the default + * constructor of the first non serializable class will be called) + * + * @param clazz Class to instantiate + * @return New instance of clazz + */ + public static Serializable newSerializableInstance(Class clazz) { + return (Serializable) OBJENESIS_SERIALIZER.newInstance(clazz); + } + + /** + * Will pick the best instantiator for the provided class. If you need to create a lot of + * instances from the same class, it is way more efficient to create them from the same + * ObjectInstantiator than calling {@link #newInstance(Class)}. + * + * @param clazz Class to instantiate + * @return Instantiator dedicated to the class + */ + public static ObjectInstantiator getInstantiatorOf(Class clazz) { + return OBJENESIS_STD.getInstantiatorOf(clazz); + } + + /** + * Same as {@link #getInstantiatorOf(Class)} but providing an instantiator emulating + * ObjectInputStream.readObject behavior. + * + * @see #newSerializableInstance(Class) + * @param clazz Class to instantiate + * @return Instantiator dedicated to the class + */ + public static ObjectInstantiator getSerializableObjectInstantiatorOf(Class clazz) { + return OBJENESIS_SERIALIZER.getInstantiatorOf(clazz); + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/Objenesis.java objenesis-1.2+full/main/src/org/objenesis/Objenesis.java --- objenesis-1.2/main/src/org/objenesis/Objenesis.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/Objenesis.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,44 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Common interface to all kind of Objenesis objects + * + * @author Henri Tremblay + */ +public interface Objenesis { + + /** + * Will create a new object without any constructor being called + * + * @param clazz Class to instantiate + * @return New instance of clazz + */ + Object newInstance(Class clazz); + + /** + * Will pick the best instantiator for the provided class. If you need to create a lot of + * instances from the same class, it is way more efficient to create them from the same + * ObjectInstantiator than calling {@link #newInstance(Class)}. + * + * @param clazz Class to instantiate + * @return Instantiator dedicated to the class + */ + ObjectInstantiator getInstantiatorOf(Class clazz); +} diff -Nru objenesis-1.2/main/src/org/objenesis/ObjenesisSerializer.java objenesis-1.2+full/main/src/org/objenesis/ObjenesisSerializer.java --- objenesis-1.2/main/src/org/objenesis/ObjenesisSerializer.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/ObjenesisSerializer.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,43 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import org.objenesis.strategy.SerializingInstantiatorStrategy; + +/** + * Objenesis implementation using the {@link SerializingInstantiatorStrategy}. + * + * @author Henri Tremblay + */ +public class ObjenesisSerializer extends ObjenesisBase { + + /** + * Default constructor using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} + */ + public ObjenesisSerializer() { + super(new SerializingInstantiatorStrategy()); + } + + /** + * Instance using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} with or without caching + * {@link org.objenesis.instantiator.ObjectInstantiator}s + * + * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached + */ + public ObjenesisSerializer(boolean useCache) { + super(new SerializingInstantiatorStrategy(), useCache); + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/ObjenesisStd.java objenesis-1.2+full/main/src/org/objenesis/ObjenesisStd.java --- objenesis-1.2/main/src/org/objenesis/ObjenesisStd.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/ObjenesisStd.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,43 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import org.objenesis.strategy.StdInstantiatorStrategy; + +/** + * Objenesis implementation using the {@link org.objenesis.strategy.StdInstantiatorStrategy}. + * + * @author Henri Tremblay + */ +public class ObjenesisStd extends ObjenesisBase { + + /** + * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy} + */ + public ObjenesisStd() { + super(new StdInstantiatorStrategy()); + } + + /** + * Instance using the {@link org.objenesis.strategy.StdInstantiatorStrategy} with or without + * caching {@link org.objenesis.instantiator.ObjectInstantiator}s + * + * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached + */ + public ObjenesisStd(boolean useCache) { + super(new StdInstantiatorStrategy(), useCache); + } +} diff -Nru objenesis-1.2/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java objenesis-1.2+full/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java --- objenesis-1.2/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/strategy/BaseInstantiatorStrategy.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,51 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.strategy; + +/** + * Base {@link InstantiatorStrategy} class basically containing helpful constant to sort out JVMs. + * + * @author Henri Tremblay + */ +public abstract class BaseInstantiatorStrategy implements InstantiatorStrategy { + + /** JVM_NAME prefix for JRockit */ + protected static final String JROCKIT = "BEA"; + + /** JVM_NAME prefix for GCJ */ + protected static final String GNU = "GNU libgcj"; + + /** JVM_NAME prefix for Sun Java HotSpot */ + protected static final String SUN = "Java HotSpot"; + + /** JVM_NAME prefix for Aonix PERC */ + protected static final String PERC = "PERC"; + + /** JVM version */ + protected static final String VM_VERSION = System.getProperty("java.runtime.version"); + + /** JVM version */ + protected static final String VM_INFO = System.getProperty("java.vm.info"); + + /** Vendor version */ + protected static final String VENDOR_VERSION = System.getProperty("java.vm.version"); + + /** Vendor name */ + protected static final String VENDOR = System.getProperty("java.vm.vendor"); + + /** JVM name */ + protected static final String JVM_NAME = System.getProperty("java.vm.name"); +} diff -Nru objenesis-1.2/main/src/org/objenesis/strategy/InstantiatorStrategy.java objenesis-1.2+full/main/src/org/objenesis/strategy/InstantiatorStrategy.java --- objenesis-1.2/main/src/org/objenesis/strategy/InstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/strategy/InstantiatorStrategy.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,34 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.strategy; + +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * Defines a strategy to determine the best instantiator for a class. + * + * @author Henri Tremblay + */ +public interface InstantiatorStrategy { + + /** + * Create a dedicated instantiator for the given class + * + * @param type Class that will be instantiate + * @return Dedicated instantiator + */ + ObjectInstantiator newInstantiatorOf(Class type); +} diff -Nru objenesis-1.2/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java objenesis-1.2+full/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java --- objenesis-1.2/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/strategy/SerializingInstantiatorStrategy.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,71 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.strategy; + +import java.io.NotSerializableException; +import java.io.Serializable; + +import org.objenesis.ObjenesisException; +import org.objenesis.instantiator.ObjectInstantiator; +import org.objenesis.instantiator.basic.ObjectStreamClassInstantiator; +import org.objenesis.instantiator.gcj.GCJSerializationInstantiator; +import org.objenesis.instantiator.perc.PercSerializationInstantiator; +import org.objenesis.instantiator.sun.Sun13SerializationInstantiator; + +/** + * Guess the best serializing instantiator for a given class. The returned instantiator will + * instantiate classes like the genuine java serialization framework (the constructor of the first + * not serializable class will be called). Currently, the selection doesn't depend on the class. It + * relies on the + *

    + *
  • JVM version
  • + *
  • JVM vendor
  • + *
  • JVM vendor version
  • + *
+ * However, instantiators are stateful and so dedicated to their class. + * + * @author Henri Tremblay + * @see ObjectInstantiator + */ +public class SerializingInstantiatorStrategy extends BaseInstantiatorStrategy { + + /** + * Return an {@link ObjectInstantiator} allowing to create instance following the java + * serialization framework specifications. + * + * @param type Class to instantiate + * @return The ObjectInstantiator for the class + */ + public ObjectInstantiator newInstantiatorOf(Class type) { + if(!Serializable.class.isAssignableFrom(type)) { + throw new ObjenesisException(new NotSerializableException(type+" not serializable")); + } + if(JVM_NAME.startsWith(SUN)) { + if(VM_VERSION.startsWith("1.3")) { + return new Sun13SerializationInstantiator(type); + } + } + else if(JVM_NAME.startsWith(GNU)) { + return new GCJSerializationInstantiator(type); + } + else if(JVM_NAME.startsWith(PERC)) { + return new PercSerializationInstantiator(type); + } + + return new ObjectStreamClassInstantiator(type); + } + +} diff -Nru objenesis-1.2/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java objenesis-1.2+full/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java --- objenesis-1.2/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/src/org/objenesis/strategy/StdInstantiatorStrategy.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,87 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.strategy; + +import org.objenesis.instantiator.ObjectInstantiator; +import org.objenesis.instantiator.gcj.GCJInstantiator; +import org.objenesis.instantiator.jrockit.JRockit131Instantiator; +import org.objenesis.instantiator.jrockit.JRockitLegacyInstantiator; +import org.objenesis.instantiator.perc.PercInstantiator; +import org.objenesis.instantiator.sun.Sun13Instantiator; +import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator; + +/** + * Guess the best instantiator for a given class. The instantiator will instantiate the class + * without calling any constructor. Currently, the selection doesn't depend on the class. It relies + * on the + *
    + *
  • JVM version
  • + *
  • JVM vendor
  • + *
  • JVM vendor version
  • + *
+ * However, instantiators are stateful and so dedicated to their class. + * + * @author Henri Tremblay + * @see ObjectInstantiator + */ +public class StdInstantiatorStrategy extends BaseInstantiatorStrategy { + + /** + * Return an {@link ObjectInstantiator} allowing to create instance without any constructor being + * called. + * + * @param type Class to instantiate + * @return The ObjectInstantiator for the class + */ + public ObjectInstantiator newInstantiatorOf(Class type) { + + if(JVM_NAME.startsWith(SUN)) { + if(VM_VERSION.startsWith("1.3")) { + return new Sun13Instantiator(type); + } + } + else if(JVM_NAME.startsWith(JROCKIT)) { + if(VM_VERSION.startsWith("1.3")) { + return new JRockit131Instantiator(type); + } + else if(VM_VERSION.startsWith("1.4")) { + // JRockit vendor version will be RXX where XX is the version + // Versions prior to 26 need special handling + // From R26 on, java.vm.version starts with R + if(!VENDOR_VERSION.startsWith("R")) { + // On R25.1 and R25.2, ReflectionFactory should work. Otherwise, we must use the + // Legacy instantiator. + if(VM_INFO == null || !VM_INFO.startsWith("R25.1") || !VM_INFO.startsWith("R25.2")) { + return new JRockitLegacyInstantiator(type); + } + } + } + } + else if(JVM_NAME.startsWith(GNU)) { + return new GCJInstantiator(type); + } + else if(JVM_NAME.startsWith(PERC)) { + return new PercInstantiator(type); + } + + // Fallback instantiator, should work with: + // - Java Hotspot version 1.4 and higher + // - JRockit 1.4-R26 and higher + // - IBM and Hitachi JVMs + // ... might works for others so we just give it a try + return new SunReflectionFactoryInstantiator(type); + } +} diff -Nru objenesis-1.2/main/test/org/objenesis/ObjenesisExceptionTest.java objenesis-1.2+full/main/test/org/objenesis/ObjenesisExceptionTest.java --- objenesis-1.2/main/test/org/objenesis/ObjenesisExceptionTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/test/org/objenesis/ObjenesisExceptionTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,54 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import junit.framework.TestCase; + +/** + * @author Henri Tremblay + */ +public class ObjenesisExceptionTest extends TestCase { + + public final void testObjenesisExceptionString() { + Exception e = new ObjenesisException("test"); + assertEquals("test", e.getMessage()); + } + + public final void testObjenesisExceptionThrowable() { + Exception cause = new RuntimeException("test"); + Exception e = new ObjenesisException(cause); + assertSame(cause, e.getCause()); + assertEquals(cause.toString(), e.getMessage()); + + // Check null case + e = new ObjenesisException((Throwable) null); + assertNull(e.getCause()); + assertEquals(null, e.getMessage()); + } + + public final void testObjenesisExceptionStringThrowable() { + Exception cause = new RuntimeException("test"); + Exception e = new ObjenesisException("msg", cause); + assertSame(cause, e.getCause()); + assertEquals("msg", e.getMessage()); + + // Check null case + e = new ObjenesisException("test", null); + assertNull(e.getCause()); + assertEquals("test", e.getMessage()); + } + +} diff -Nru objenesis-1.2/main/test/org/objenesis/ObjenesisTest.java objenesis-1.2+full/main/test/org/objenesis/ObjenesisTest.java --- objenesis-1.2/main/test/org/objenesis/ObjenesisTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/test/org/objenesis/ObjenesisTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,72 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import junit.framework.TestCase; + +import org.objenesis.instantiator.ObjectInstantiator; +import org.objenesis.strategy.InstantiatorStrategy; + +/** + * @author Henri Tremblay + */ +public class ObjenesisTest extends TestCase { + + public final void testObjenesis() { + Objenesis o = new ObjenesisStd(); + assertEquals( + "org.objenesis.ObjenesisStd using org.objenesis.strategy.StdInstantiatorStrategy with caching", + o.toString()); + } + + public final void testObjenesis_WithoutCache() { + Objenesis o = new ObjenesisStd(false); + assertEquals( + "org.objenesis.ObjenesisStd using org.objenesis.strategy.StdInstantiatorStrategy without caching", + o.toString()); + + assertEquals(o.getInstantiatorOf(getClass()).newInstance().getClass(), getClass()); + } + + public final void testNewInstance() { + Objenesis o = new ObjenesisStd(); + assertEquals(getClass(), o.newInstance(getClass()).getClass()); + } + + public final void testGetInstantiatorOf() { + Objenesis o = new ObjenesisStd(); + ObjectInstantiator i1 = o.getInstantiatorOf(getClass()); + // Test instance creation + assertEquals(getClass(), i1.newInstance().getClass()); + + // Test caching + ObjectInstantiator i2 = o.getInstantiatorOf(getClass()); + assertSame(i1, i2); + } + + public final void testToString() { + Objenesis o = new ObjenesisStd() {}; + assertEquals( + "org.objenesis.ObjenesisTest$1 using org.objenesis.strategy.StdInstantiatorStrategy with caching", + o.toString()); + } +} + +class MyStrategy implements InstantiatorStrategy { + public ObjectInstantiator newInstantiatorOf(Class type) { + return null; + } +} diff -Nru objenesis-1.2/main/test/org/objenesis/SerializingInstantiatorTest.java objenesis-1.2+full/main/test/org/objenesis/SerializingInstantiatorTest.java --- objenesis-1.2/main/test/org/objenesis/SerializingInstantiatorTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/main/test/org/objenesis/SerializingInstantiatorTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,45 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis; + +import java.io.NotSerializableException; + +import junit.framework.TestCase; + +/** + * @author Henri Tremblay + * @author Leonardo Mesquita + */ +public class SerializingInstantiatorTest extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testNotSerializable() { + ObjenesisSerializer o = new ObjenesisSerializer(); + try { + o.newInstance(Object.class); + fail("Should have thrown an exception"); + } catch (ObjenesisException e) { + assertTrue(e.getCause() instanceof NotSerializableException); + } + } +} diff -Nru objenesis-1.2/META-INF/LICENSE objenesis-1.2+full/META-INF/LICENSE --- objenesis-1.2/META-INF/LICENSE 2009-08-26 22:13:18.000000000 +0000 +++ objenesis-1.2+full/META-INF/LICENSE 1970-01-01 00:00:00.000000000 +0000 @@ -1,202 +0,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 -Nru objenesis-1.2/META-INF/MANIFEST.MF objenesis-1.2+full/META-INF/MANIFEST.MF --- objenesis-1.2/META-INF/MANIFEST.MF 2009-08-26 22:13:20.000000000 +0000 +++ objenesis-1.2+full/META-INF/MANIFEST.MF 1970-01-01 00:00:00.000000000 +0000 @@ -1,4 +0,0 @@ -Manifest-Version: 1.0 -Archiver-Version: Plexus Archiver -Created-By: 14.1-b02 (Sun Microsystems Inc.) - diff -Nru objenesis-1.2/META-INF/NOTICE objenesis-1.2+full/META-INF/NOTICE --- objenesis-1.2/META-INF/NOTICE 2009-08-26 22:13:18.000000000 +0000 +++ objenesis-1.2+full/META-INF/NOTICE 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -// ------------------------------------------------------------------ -// NOTICE file corresponding to the section 4d of The Apache License, -// Version 2.0, in this case for Objenesis -// ------------------------------------------------------------------ - -Objenesis -Copyright 2006-2009 Joe Walnes, Henri Tremblay, Leonardo Mesquita - - diff -Nru objenesis-1.2/objenesis-formatting.xml objenesis-1.2+full/objenesis-formatting.xml --- objenesis-1.2/objenesis-formatting.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/objenesis-formatting.xml 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru objenesis-1.2/org/objenesis/instantiator/basic/AccessibleInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/basic/AccessibleInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/basic/AccessibleInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/basic/AccessibleInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.basic; - -/** - * Instantiates a class by grabbing the no-args constructor, making it accessible and then calling - * Constructor.newInstance(). Although this still requires no-arg constructors, it can call - * non-public constructors (if the security manager allows it). - * - * @author Joe Walnes - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class AccessibleInstantiator extends ConstructorInstantiator { - - public AccessibleInstantiator(Class type) { - super(type); - if(constructor != null) { - constructor.setAccessible(true); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/basic/ConstructorInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/basic/ConstructorInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/basic/ConstructorInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/basic/ConstructorInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,52 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.basic; - -import java.lang.reflect.Constructor; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by grabbing the no args constructor and calling Constructor.newInstance(). - * This can deal with default public constructors, but that's about it. - * - * @author Joe Walnes - * @see ObjectInstantiator - */ -public class ConstructorInstantiator implements ObjectInstantiator { - - protected Constructor constructor; - - public ConstructorInstantiator(Class type) { - try { - constructor = type.getDeclaredConstructor((Class[]) null); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - - public Object newInstance() { - try { - return constructor.newInstance((Object[]) null); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/basic/NewInstanceInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/basic/NewInstanceInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/basic/NewInstanceInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,45 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.basic; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public - * constructors, but that's about it. - * - * @author Joe Walnes - * @see ObjectInstantiator - */ -public class NewInstanceInstantiator implements ObjectInstantiator { - - private final Class type; - - public NewInstanceInstantiator(Class type) { - this.type = type; - } - - public Object newInstance() { - try { - return type.newInstance(); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/basic/ObjectInputStreamInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,179 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.basic; - -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.NotSerializableException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamClass; -import java.io.ObjectStreamConstants; -import java.io.Serializable; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by using a dummy input stream that always feeds data for an empty object of - * the same kind. NOTE: This instantiator may not work properly if the class being instantiated - * defines a "readResolve" method, since it may return objects that have been returned previously - * (i.e., there's no guarantee that the returned object is a new one), or even objects from a - * completely different class. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class ObjectInputStreamInstantiator implements ObjectInstantiator { - private static class MockStream extends InputStream { - - private int pointer; - private byte[] data; - private int sequence; - private static final int[] NEXT = new int[] {1, 2, 2}; - private byte[][] buffers; - - private final byte[] FIRST_DATA; - private static byte[] HEADER; - private static byte[] REPEATING_DATA; - - static { - initialize(); - } - - private static void initialize() { - try { - ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); - DataOutputStream dout = new DataOutputStream(byteOut); - dout.writeShort(ObjectStreamConstants.STREAM_MAGIC); - dout.writeShort(ObjectStreamConstants.STREAM_VERSION); - HEADER = byteOut.toByteArray(); - - byteOut = new ByteArrayOutputStream(); - dout = new DataOutputStream(byteOut); - - dout.writeByte(ObjectStreamConstants.TC_OBJECT); - dout.writeByte(ObjectStreamConstants.TC_REFERENCE); - dout.writeInt(ObjectStreamConstants.baseWireHandle); - REPEATING_DATA = byteOut.toByteArray(); - } - catch(IOException e) { - throw new Error("IOException: " + e.getMessage()); - } - - } - - public MockStream(Class clazz) { - this.pointer = 0; - this.sequence = 0; - this.data = HEADER; - - // (byte) TC_OBJECT - // (byte) TC_CLASSDESC - // (short length) - // (byte * className.length) - // (long)serialVersionUID - // (byte) SC_SERIALIZABLE - // (short)0 - // TC_ENDBLOCKDATA - // TC_NULL - ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); - DataOutputStream dout = new DataOutputStream(byteOut); - try { - dout.writeByte(ObjectStreamConstants.TC_OBJECT); - dout.writeByte(ObjectStreamConstants.TC_CLASSDESC); - dout.writeUTF(clazz.getName()); - dout.writeLong(ObjectStreamClass.lookup(clazz).getSerialVersionUID()); - dout.writeByte(ObjectStreamConstants.SC_SERIALIZABLE); - dout.writeShort((short) 0); // Zero fields - dout.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); - dout.writeByte(ObjectStreamConstants.TC_NULL); - } - catch(IOException e) { - throw new Error("IOException: " + e.getMessage()); - } - this.FIRST_DATA = byteOut.toByteArray(); - buffers = new byte[][] {HEADER, FIRST_DATA, REPEATING_DATA}; - } - - private void advanceBuffer() { - pointer = 0; - sequence = NEXT[sequence]; - data = buffers[sequence]; - } - - public int read() throws IOException { - int result = data[pointer++]; - if(pointer >= data.length) { - advanceBuffer(); - } - - return result; - } - - public int available() throws IOException { - return Integer.MAX_VALUE; - } - - public int read(byte[] b, int off, int len) throws IOException { - int left = len; - int remaining = data.length - pointer; - - while(remaining <= left) { - System.arraycopy(data, pointer, b, off, remaining); - off += remaining; - left -= remaining; - advanceBuffer(); - remaining = data.length - pointer; - } - if(left > 0) { - System.arraycopy(data, pointer, b, off, left); - pointer += left; - } - - return len; - } - } - - private ObjectInputStream inputStream; - - public ObjectInputStreamInstantiator(Class clazz) { - if(Serializable.class.isAssignableFrom(clazz)) { - try { - this.inputStream = new ObjectInputStream(new MockStream(clazz)); - } - catch(IOException e) { - throw new Error("IOException: " + e.getMessage()); - } - } - else { - throw new ObjenesisException(new NotSerializableException(clazz+" not serializable")); - } - } - - public Object newInstance() { - try { - return inputStream.readObject(); - } - catch(ClassNotFoundException e) { - throw new Error("ClassNotFoundException: " + e.getMessage()); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/basic/ObjectStreamClassInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,72 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.basic; - -import java.io.ObjectStreamClass; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by using reflection to make a call to private method - * ObjectStreamClass.newInstance, present in many JVM implementations. This instantiator will create - * classes in a way compatible with serialization, calling the first non-serializable superclass' - * no-arg constructor. - * - * @author Leonardo Mesquita - * @see ObjectInstantiator - * @see java.io.Serializable - */ -public class ObjectStreamClassInstantiator implements ObjectInstantiator { - - private static Method newInstanceMethod; - - private static void initialize() { - if(newInstanceMethod == null) { - try { - newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance", - new Class[] {}); - newInstanceMethod.setAccessible(true); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - } - } - - private final ObjectStreamClass objStreamClass; - - public ObjectStreamClassInstantiator(Class type) { - initialize(); - objStreamClass = ObjectStreamClass.lookup(type); - } - - public Object newInstance() { - - try { - return newInstanceMethod.invoke(objStreamClass, new Object[] {}); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java --- objenesis-1.2/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,69 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.gcj; - -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Base class for GCJ-based instantiators. It initializes reflection access to method - * ObjectInputStream.newObject, as well as creating a dummy ObjectInputStream to be used as the - * "this" argument for the method. - * - * @author Leonardo Mesquita - */ -public abstract class GCJInstantiatorBase implements ObjectInstantiator { - protected static Method newObjectMethod = null; - protected static ObjectInputStream dummyStream; - - private static class DummyStream extends ObjectInputStream { - public DummyStream() throws IOException { - } - } - - private static void initialize() { - if(newObjectMethod == null) { - try { - newObjectMethod = ObjectInputStream.class.getDeclaredMethod("newObject", new Class[] { - Class.class, Class.class}); - newObjectMethod.setAccessible(true); - dummyStream = new DummyStream(); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - catch(IOException e) { - throw new ObjenesisException(e); - } - } - } - - protected final Class type; - - public GCJInstantiatorBase(Class type) { - this.type = type; - initialize(); - } - - public abstract Object newInstance(); -} diff -Nru objenesis-1.2/org/objenesis/instantiator/gcj/GCJInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/gcj/GCJInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.gcj; - -import java.lang.reflect.InvocationTargetException; - -import org.objenesis.ObjenesisException; - -/** - * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to - * work on GCJ JVMs. This instantiator will not call any constructors. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class GCJInstantiator extends GCJInstantiatorBase { - public GCJInstantiator(Class type) { - super(type); - } - - public Object newInstance() { - try { - return newObjectMethod.invoke(dummyStream, new Object[] {type, Object.class}); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(IllegalAccessException e) { - throw new ObjenesisException(e); - } - catch(InvocationTargetException e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.gcj; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.SerializationInstantiatorHelper; - -/** - * Instantiates a class by making a call to internal GCJ private methods. It is only supposed to - * work on GCJ JVMs. This instantiator will create classes in a way compatible with serialization, - * calling the first non-serializable superclass' no-arg constructor. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class GCJSerializationInstantiator extends GCJInstantiatorBase { - private Class superType; - - public GCJSerializationInstantiator(Class type) { - super(type); - this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); - } - - public Object newInstance() { - try { - return newObjectMethod.invoke(dummyStream, new Object[] {type, superType}); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java objenesis-1.2+full/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java --- objenesis-1.2/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 2009-06-21 23:45:56.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/jrockit/JRockit131Instantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,89 +0,0 @@ -/** - * COPYRIGHT & LICENSE - * - * This code is Copyright (c) 2006 BEA Systems, inc. It is provided free, as-is and without any warranties for the purpose of - * inclusion in Objenesis or any other open source project with a FSF approved license, as long as this notice is not - * removed. There are no limitations on modifying or repackaging the code apart from this. - * - * BEA does not guarantee that the code works, and provides no support for it. Use at your own risk. - * - * Originally developed by Leonardo Mesquita. Copyright notice added by Henrik Ståhl, BEA JRockit Product Manager. - * - */ -package org.objenesis.instantiator.jrockit; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by making a call to internal JRockit private methods. It is only supposed to - * work on JRockit 7.0 JVMs, which are compatible with Java API 1.3.1. This instantiator will not - * call any constructors. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class JRockit131Instantiator implements ObjectInstantiator { - - private Constructor mungedConstructor; - - private static Method newConstructorForSerializationMethod; - - private static void initialize() { - if(newConstructorForSerializationMethod == null) { - Class cl; - try { - cl = Class.forName("COM.jrockit.reflect.MemberAccess"); - newConstructorForSerializationMethod = cl.getDeclaredMethod( - "newConstructorForSerialization", new Class[] {Constructor.class, Class.class}); - newConstructorForSerializationMethod.setAccessible(true); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(ClassNotFoundException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - } - } - - public JRockit131Instantiator(Class type) { - initialize(); - - if(newConstructorForSerializationMethod != null) { - - Constructor javaLangObjectConstructor; - - try { - javaLangObjectConstructor = Object.class.getConstructor((Class[]) null); - } - catch(NoSuchMethodException e) { - throw new Error("Cannot find constructor for java.lang.Object!"); - } - - try { - mungedConstructor = (Constructor) newConstructorForSerializationMethod.invoke(null, - new Object[] {javaLangObjectConstructor, type}); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - - } - - public Object newInstance() { - try { - return mungedConstructor.newInstance((Object[]) null); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 2009-06-21 23:46:50.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/jrockit/JRockitLegacyInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,70 +0,0 @@ -/** - * COPYRIGHT & LICENSE - * - * This code is Copyright (c) 2006 BEA Systems, inc. It is provided free, as-is and without any warranties for the purpose of - * inclusion in Objenesis or any other open source project with a FSF approved license, as long as this notice is not - * removed. There are no limitations on modifying or repackaging the code apart from this. - * - * BEA does not guarantee that the code works, and provides no support for it. Use at your own risk. - * - * Originally developed by Leonardo Mesquita. Copyright notice added by Henrik Ståhl, BEA JRockit Product Manager. - * - */ - -package org.objenesis.instantiator.jrockit; - -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by making a call to internal JRockit private methods. It is only supposed to - * work on JRockit 1.4.2 JVMs prior to release R25.1. From release R25.1 on, JRockit supports - * sun.reflect.ReflectionFactory, making this "trick" unnecessary. This instantiator will not call - * any constructors. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - * @see org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator - */ -public class JRockitLegacyInstantiator implements ObjectInstantiator { - private static Method safeAllocObjectMethod = null; - - private static void initialize() { - if(safeAllocObjectMethod == null) { - Class memSystem; - try { - memSystem = Class.forName("jrockit.vm.MemSystem"); - safeAllocObjectMethod = memSystem.getDeclaredMethod("safeAllocObject", - new Class[] {Class.class}); - safeAllocObjectMethod.setAccessible(true); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(ClassNotFoundException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - } - } - - private final Class type; - - public JRockitLegacyInstantiator(Class type) { - initialize(); - this.type = type; - } - - public Object newInstance() { - try { - return safeAllocObjectMethod.invoke(null, new Object[] {type}); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/NullInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/NullInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/NullInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/NullInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,31 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator; - -/** - * The instantiator that always return a null instance - * - * @author Henri Tremblay - */ -public class NullInstantiator implements ObjectInstantiator { - - /** - * @return Always null - */ - public Object newInstance() { - return null; - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/ObjectInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/ObjectInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/ObjectInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/ObjectInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator; - -/** - * Instantiates a new object. - * - * @author Leonardo Mesquita - */ -public interface ObjectInstantiator { - - /** - * Returns a new instance of an object. The returned object's class is defined by the - * implementation. - * - * @return A new instance of an object. - */ - Object newInstance(); - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/perc/PercInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/perc/PercInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/perc/PercInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/perc/PercInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,63 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.perc; - -import java.io.ObjectInputStream; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by making a call to internal Perc private methods. It is only supposed to - * work on Perc JVMs. This instantiator will not call any constructors. The code was provided by - * Aonix Perc support team. - * - * @author Henri Tremblay - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class PercInstantiator implements ObjectInstantiator { - - private final Method newInstanceMethod; - - private final Object[] typeArgs = new Object[] { null, Boolean.FALSE }; - - public PercInstantiator(Class type) { - - typeArgs[0] = type; - - try { - newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("newInstance", - new Class[] { Class.class, Boolean.TYPE }); - newInstanceMethod.setAccessible(true); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - } - - public Object newInstance() { - try { - return newInstanceMethod.invoke(null, typeArgs); - } catch (Exception e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/perc/PercSerializationInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/perc/PercSerializationInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/perc/PercSerializationInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/perc/PercSerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.perc; - -import java.io.ObjectInputStream; -import java.io.Serializable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Instantiates a class by making a call to internal Perc private methods. It is only supposed to - * work on Perc JVMs. This instantiator will create classes in a way compatible with serialization, - * calling the first non-serializable superclass' no-arg constructor.

Based on code provided by - * Aonix but doesn't work right now - * - * @author Henri Tremblay - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class PercSerializationInstantiator implements ObjectInstantiator { - - private Object[] typeArgs; - - private final java.lang.reflect.Method newInstanceMethod; - - public PercSerializationInstantiator(Class type) { - - // Find the first unserializable parent class - Class unserializableType = type; - - while(Serializable.class.isAssignableFrom(unserializableType)) { - unserializableType = unserializableType.getSuperclass(); - } - - try { - // Get the special Perc method to call - Class percMethodClass = Class.forName("COM.newmonics.PercClassLoader.Method"); - - newInstanceMethod = ObjectInputStream.class.getDeclaredMethod("noArgConstruct", - new Class[] {Class.class, Object.class, percMethodClass}); - newInstanceMethod.setAccessible(true); - - // Create invoke params - Class percClassClass = Class.forName("COM.newmonics.PercClassLoader.PercClass"); - Method getPercClassMethod = percClassClass.getDeclaredMethod("getPercClass", - new Class[] {Class.class}); - Object someObject = getPercClassMethod.invoke(null, new Object[] {unserializableType}); - Method findMethodMethod = someObject.getClass().getDeclaredMethod("findMethod", - new Class[] {String.class}); - Object percMethod = findMethodMethod.invoke(someObject, new Object[] {"()V"}); - - typeArgs = new Object[] {unserializableType, type, percMethod}; - - } - catch(ClassNotFoundException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - catch(InvocationTargetException e) { - throw new ObjenesisException(e); - } - catch(IllegalAccessException e) { - throw new ObjenesisException(e); - } - } - - public Object newInstance() { - try { - return newInstanceMethod.invoke(null, typeArgs); - } - catch(IllegalAccessException e) { - throw new ObjenesisException(e); - } - catch(InvocationTargetException e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/SerializationInstantiatorHelper.java objenesis-1.2+full/org/objenesis/instantiator/SerializationInstantiatorHelper.java --- objenesis-1.2/org/objenesis/instantiator/SerializationInstantiatorHelper.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/SerializationInstantiatorHelper.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator; - -import java.io.Serializable; - -/** - * Helper for common serialization-compatible instantiation functions - * - * @author Leonardo Mesquita - */ -public class SerializationInstantiatorHelper { - - /** - * Returns the first non-serializable superclass of a given class. According to Java Object - * Serialization Specification, objects read from a stream are initialized by calling an - * accessible no-arg constructor from the first non-serializable superclass in the object's - * hierarchy, allowing the state of non-serializable fields to be correctly initialized. - * - * @param type Serializable class for which the first non-serializable superclass is to be found - * @return The first non-serializable superclass of 'type'. - * @see java.io.Serializable - */ - public static Class getNonSerializableSuperClass(Class type) { - Class result = type; - while(Serializable.class.isAssignableFrom(result)) { - result = result.getSuperclass(); - if(result == null) { - throw new Error("Bad class hierarchy: No non-serializable parents"); - } - } - return result; - - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java --- objenesis-1.2/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13InstantiatorBase.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,58 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.sun; - -import java.io.ObjectInputStream; -import java.lang.reflect.Method; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Base class for Sun 1.3 based instantiators. It initializes reflection access to static method - * ObjectInputStream.allocateNewObject. - * - * @author Leonardo Mesquita - */ -public abstract class Sun13InstantiatorBase implements ObjectInstantiator { - protected static Method allocateNewObjectMethod = null; - - private static void initialize() { - if(allocateNewObjectMethod == null) { - try { - allocateNewObjectMethod = ObjectInputStream.class.getDeclaredMethod( - "allocateNewObject", new Class[] {Class.class, Class.class}); - allocateNewObjectMethod.setAccessible(true); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(NoSuchMethodException e) { - throw new ObjenesisException(e); - } - } - } - - protected final Class type; - - public Sun13InstantiatorBase(Class type) { - this.type = type; - initialize(); - } - - public abstract Object newInstance(); - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/sun/Sun13Instantiator.java objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13Instantiator.java --- objenesis-1.2/org/objenesis/instantiator/sun/Sun13Instantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13Instantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,49 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.sun; - -import java.lang.reflect.InvocationTargetException; - -import org.objenesis.ObjenesisException; - -/** - * Instantiates a class by making a call to internal Sun private methods. It is only supposed to - * work on Sun HotSpot 1.3 JVM. This instantiator will not call any constructors. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class Sun13Instantiator extends Sun13InstantiatorBase { - public Sun13Instantiator(Class type) { - super(type); - } - - public Object newInstance() { - try { - return allocateNewObjectMethod.invoke(null, new Object[] {type, Object.class}); - } - catch(RuntimeException e) { - throw new ObjenesisException(e); - } - catch(IllegalAccessException e) { - throw new ObjenesisException(e); - } - catch(InvocationTargetException e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/sun/Sun13SerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,46 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.sun; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.SerializationInstantiatorHelper; - -/** - * Instantiates a class by making a call to internal Sun private methods. It is only supposed to - * work on Sun HotSpot 1.3 JVM. This instantiator will create classes in a way compatible with - * serialization, calling the first non-serializable superclass' no-arg constructor. - * - * @author Leonardo Mesquita - * @see org.objenesis.instantiator.ObjectInstantiator - */ -public class Sun13SerializationInstantiator extends Sun13InstantiatorBase { - private final Class superType; - - public Sun13SerializationInstantiator(Class type) { - super(type); - this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); - } - - public Object newInstance() { - try { - return allocateNewObjectMethod.invoke(null, new Object[] {type, superType}); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } - -} diff -Nru objenesis-1.2/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/sun/SunReflectionFactoryInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,62 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.sun; - -import java.lang.reflect.Constructor; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; - -import sun.reflect.ReflectionFactory; - -/** - * Instantiates an object, WITHOUT calling it's constructor, using internal - * sun.reflect.ReflectionFactory - a class only available on JDK's that use Sun's 1.4 (or later) - * Java implementation. This is the best way to instantiate an object without any side effects - * caused by the constructor - however it is not available on every platform. - * - * @author Joe Walnes - * @see ObjectInstantiator - */ -public class SunReflectionFactoryInstantiator implements ObjectInstantiator { - - private final Constructor mungedConstructor; - - public SunReflectionFactoryInstantiator(Class type) { - - ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); - Constructor javaLangObjectConstructor; - - try { - javaLangObjectConstructor = Object.class.getConstructor((Class[]) null); - } - catch(NoSuchMethodException e) { - throw new Error("Cannot find constructor for java.lang.Object!"); - } - mungedConstructor = reflectionFactory.newConstructorForSerialization(type, - javaLangObjectConstructor); - mungedConstructor.setAccessible(true); - } - - public Object newInstance() { - try { - return mungedConstructor.newInstance((Object[]) null); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java objenesis-1.2+full/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java --- objenesis-1.2/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/instantiator/sun/SunReflectionFactorySerializationInstantiator.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,73 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.instantiator.sun; - -import java.io.NotSerializableException; -import java.lang.reflect.Constructor; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; -import org.objenesis.instantiator.SerializationInstantiatorHelper; - -import sun.reflect.ReflectionFactory; - -/** - * Instantiates an object using internal sun.reflect.ReflectionFactory - a class only available on - * JDK's that use Sun's 1.4 (or later) Java implementation. This instantiator will create classes in - * a way compatible with serialization, calling the first non-serializable superclass' no-arg - * constructor. This is the best way to instantiate an object without any side effects caused by the - * constructor - however it is not available on every platform. - * - * @author Leonardo Mesquita - * @see ObjectInstantiator - */ -public class SunReflectionFactorySerializationInstantiator implements ObjectInstantiator { - - private final Constructor mungedConstructor; - - public SunReflectionFactorySerializationInstantiator(Class type) { - - Class nonSerializableAncestor = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); - ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); - Constructor nonSerializableAncestorConstructor; - try { - nonSerializableAncestorConstructor = nonSerializableAncestor - .getConstructor((Class[]) null); - } - catch(NoSuchMethodException e) { - /** - * @todo (Henri) I think we should throw a NotSerializableException just to put the same - * message a ObjectInputStream. Otherwise, the user won't know if the null returned - * if a "Not serializable", a "No default constructor on ancestor" or a "Exception in - * constructor" - */ - throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor")); - } - - mungedConstructor = reflectionFactory.newConstructorForSerialization(type, - nonSerializableAncestorConstructor); - mungedConstructor.setAccessible(true); - } - - public Object newInstance() { - try { - return mungedConstructor.newInstance((Object[]) null); - } - catch(Exception e) { - throw new ObjenesisException(e); - } - } -} diff -Nru objenesis-1.2/org/objenesis/ObjenesisBase.java objenesis-1.2+full/org/objenesis/ObjenesisBase.java --- objenesis-1.2/org/objenesis/ObjenesisBase.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/ObjenesisBase.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -import java.util.HashMap; -import java.util.Map; - -import org.objenesis.instantiator.ObjectInstantiator; -import org.objenesis.strategy.InstantiatorStrategy; - -/** - * Base class to extend if you want to have a class providing your own default strategy. Can also be - * instantiated directly. - * - * @author Henri Tremblay - */ -public class ObjenesisBase implements Objenesis { - - /** Strategy used by this Objenesi implementation to create classes */ - protected final InstantiatorStrategy strategy; - - /** Strategy cache. Key = Class, Value = InstantiatorStrategy */ - protected Map cache; - - /** - * Constructor allowing to pick a strategy and using cache - * - * @param strategy Strategy to use - */ - public ObjenesisBase(InstantiatorStrategy strategy) { - this(strategy, true); - } - - /** - * Flexible constructor allowing to pick the strategy and if caching should be used - * - * @param strategy Strategy to use - * @param useCache If {@link ObjectInstantiator}s should be cached - */ - public ObjenesisBase(InstantiatorStrategy strategy, boolean useCache) { - if(strategy == null) { - throw new IllegalArgumentException("A strategy can't be null"); - } - this.strategy = strategy; - this.cache = useCache ? new HashMap() : null; - } - - public String toString() { - return getClass().getName() + " using " + strategy.getClass().getName() - + (cache == null ? " without" : " with") + " caching"; - } - - /** - * Will create a new object without any constructor being called - * - * @param clazz Class to instantiate - * @return New instance of clazz - */ - public Object newInstance(Class clazz) { - return getInstantiatorOf(clazz).newInstance(); - } - - /** - * Will pick the best instantiator for the provided class. If you need to create a lot of - * instances from the same class, it is way more efficient to create them from the same - * ObjectInstantiator than calling {@link #newInstance(Class)}. - * - * @param clazz Class to instantiate - * @return Instantiator dedicated to the class - */ - public synchronized ObjectInstantiator getInstantiatorOf(Class clazz) { - if(cache == null) { - return strategy.newInstantiatorOf(clazz); - } - ObjectInstantiator instantiator = (ObjectInstantiator) cache.get(clazz.getName()); - if(instantiator == null) { - instantiator = strategy.newInstantiatorOf(clazz); - cache.put(clazz.getName(), instantiator); - } - return instantiator; - } - -} diff -Nru objenesis-1.2/org/objenesis/ObjenesisException.java objenesis-1.2+full/org/objenesis/ObjenesisException.java --- objenesis-1.2/org/objenesis/ObjenesisException.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/ObjenesisException.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,59 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -/** - * Exception thrown by Objenesis. It wraps any instantiation exceptions. Note that this exception is - * runtime to prevent having to catch it. It will do normal exception wrapping for JDK 1.4 and more - * and basic message wrapping for JDK 1.3. - * - * @author Henri Tremblay - */ -public class ObjenesisException extends RuntimeException { - - private static final long serialVersionUID = -2677230016262426968L; - - private static final boolean jdk14 = (Double.parseDouble(System - .getProperty("java.specification.version")) > 1.3); - - /** - * @param msg Error message - */ - public ObjenesisException(String msg) { - super(msg); - } - - /** - * @param cause Wrapped exception. The message will be the one of the cause. - */ - public ObjenesisException(Throwable cause) { - super(cause == null ? null : cause.toString()); - if(jdk14) { - initCause(cause); - } - } - - /** - * @param msg Error message - * @param cause Wrapped exception - */ - public ObjenesisException(String msg, Throwable cause) { - super(msg); - if(jdk14) { - initCause(cause); - } - } -} diff -Nru objenesis-1.2/org/objenesis/ObjenesisHelper.java objenesis-1.2+full/org/objenesis/ObjenesisHelper.java --- objenesis-1.2/org/objenesis/ObjenesisHelper.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/ObjenesisHelper.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,80 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -import java.io.Serializable; - -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Use Objenesis in a static way. It is strongly not recommended to use this class. - * - * @author Henri Tremblay - */ -public final class ObjenesisHelper { - - private static final Objenesis OBJENESIS_STD = new ObjenesisStd(); - - private static final Objenesis OBJENESIS_SERIALIZER = new ObjenesisSerializer(); - - private ObjenesisHelper() { - } - - /** - * Will create a new object without any constructor being called - * - * @param clazz Class to instantiate - * @return New instance of clazz - */ - public static Object newInstance(Class clazz) { - return OBJENESIS_STD.newInstance(clazz); - } - - /** - * Will create an object just like it's done by ObjectInputStream.readObject (the default - * constructor of the first non serializable class will be called) - * - * @param clazz Class to instantiate - * @return New instance of clazz - */ - public static Serializable newSerializableInstance(Class clazz) { - return (Serializable) OBJENESIS_SERIALIZER.newInstance(clazz); - } - - /** - * Will pick the best instantiator for the provided class. If you need to create a lot of - * instances from the same class, it is way more efficient to create them from the same - * ObjectInstantiator than calling {@link #newInstance(Class)}. - * - * @param clazz Class to instantiate - * @return Instantiator dedicated to the class - */ - public static ObjectInstantiator getInstantiatorOf(Class clazz) { - return OBJENESIS_STD.getInstantiatorOf(clazz); - } - - /** - * Same as {@link #getInstantiatorOf(Class)} but providing an instantiator emulating - * ObjectInputStream.readObject behavior. - * - * @see #newSerializableInstance(Class) - * @param clazz Class to instantiate - * @return Instantiator dedicated to the class - */ - public static ObjectInstantiator getSerializableObjectInstantiatorOf(Class clazz) { - return OBJENESIS_SERIALIZER.getInstantiatorOf(clazz); - } -} diff -Nru objenesis-1.2/org/objenesis/Objenesis.java objenesis-1.2+full/org/objenesis/Objenesis.java --- objenesis-1.2/org/objenesis/Objenesis.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/Objenesis.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,44 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Common interface to all kind of Objenesis objects - * - * @author Henri Tremblay - */ -public interface Objenesis { - - /** - * Will create a new object without any constructor being called - * - * @param clazz Class to instantiate - * @return New instance of clazz - */ - Object newInstance(Class clazz); - - /** - * Will pick the best instantiator for the provided class. If you need to create a lot of - * instances from the same class, it is way more efficient to create them from the same - * ObjectInstantiator than calling {@link #newInstance(Class)}. - * - * @param clazz Class to instantiate - * @return Instantiator dedicated to the class - */ - ObjectInstantiator getInstantiatorOf(Class clazz); -} diff -Nru objenesis-1.2/org/objenesis/ObjenesisSerializer.java objenesis-1.2+full/org/objenesis/ObjenesisSerializer.java --- objenesis-1.2/org/objenesis/ObjenesisSerializer.java 2009-08-26 22:12:26.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/ObjenesisSerializer.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -import org.objenesis.strategy.SerializingInstantiatorStrategy; - -/** - * Objenesis implementation using the {@link SerializingInstantiatorStrategy}. - * - * @author Henri Tremblay - */ -public class ObjenesisSerializer extends ObjenesisBase { - - /** - * Default constructor using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} - */ - public ObjenesisSerializer() { - super(new SerializingInstantiatorStrategy()); - } - - /** - * Instance using the {@link org.objenesis.strategy.SerializingInstantiatorStrategy} with or without caching - * {@link org.objenesis.instantiator.ObjectInstantiator}s - * - * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached - */ - public ObjenesisSerializer(boolean useCache) { - super(new SerializingInstantiatorStrategy(), useCache); - } -} diff -Nru objenesis-1.2/org/objenesis/ObjenesisStd.java objenesis-1.2+full/org/objenesis/ObjenesisStd.java --- objenesis-1.2/org/objenesis/ObjenesisStd.java 2009-08-26 22:12:24.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/ObjenesisStd.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis; - -import org.objenesis.strategy.StdInstantiatorStrategy; - -/** - * Objenesis implementation using the {@link org.objenesis.strategy.StdInstantiatorStrategy}. - * - * @author Henri Tremblay - */ -public class ObjenesisStd extends ObjenesisBase { - - /** - * Default constructor using the {@link org.objenesis.strategy.StdInstantiatorStrategy} - */ - public ObjenesisStd() { - super(new StdInstantiatorStrategy()); - } - - /** - * Instance using the {@link org.objenesis.strategy.StdInstantiatorStrategy} with or without - * caching {@link org.objenesis.instantiator.ObjectInstantiator}s - * - * @param useCache If {@link org.objenesis.instantiator.ObjectInstantiator}s should be cached - */ - public ObjenesisStd(boolean useCache) { - super(new StdInstantiatorStrategy(), useCache); - } -} diff -Nru objenesis-1.2/org/objenesis/strategy/BaseInstantiatorStrategy.java objenesis-1.2+full/org/objenesis/strategy/BaseInstantiatorStrategy.java --- objenesis-1.2/org/objenesis/strategy/BaseInstantiatorStrategy.java 2009-08-26 22:12:24.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/strategy/BaseInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.strategy; - -/** - * Base {@link InstantiatorStrategy} class basically containing helpful constant to sort out JVMs. - * - * @author Henri Tremblay - */ -public abstract class BaseInstantiatorStrategy implements InstantiatorStrategy { - - /** JVM_NAME prefix for JRockit */ - protected static final String JROCKIT = "BEA"; - - /** JVM_NAME prefix for GCJ */ - protected static final String GNU = "GNU libgcj"; - - /** JVM_NAME prefix for Sun Java HotSpot */ - protected static final String SUN = "Java HotSpot"; - - /** JVM_NAME prefix for Aonix PERC */ - protected static final String PERC = "PERC"; - - /** JVM version */ - protected static final String VM_VERSION = System.getProperty("java.runtime.version"); - - /** JVM version */ - protected static final String VM_INFO = System.getProperty("java.vm.info"); - - /** Vendor version */ - protected static final String VENDOR_VERSION = System.getProperty("java.vm.version"); - - /** Vendor name */ - protected static final String VENDOR = System.getProperty("java.vm.vendor"); - - /** JVM name */ - protected static final String JVM_NAME = System.getProperty("java.vm.name"); -} diff -Nru objenesis-1.2/org/objenesis/strategy/InstantiatorStrategy.java objenesis-1.2+full/org/objenesis/strategy/InstantiatorStrategy.java --- objenesis-1.2/org/objenesis/strategy/InstantiatorStrategy.java 2009-08-26 22:12:24.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/strategy/InstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,34 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.strategy; - -import org.objenesis.instantiator.ObjectInstantiator; - -/** - * Defines a strategy to determine the best instantiator for a class. - * - * @author Henri Tremblay - */ -public interface InstantiatorStrategy { - - /** - * Create a dedicated instantiator for the given class - * - * @param type Class that will be instantiate - * @return Dedicated instantiator - */ - ObjectInstantiator newInstantiatorOf(Class type); -} diff -Nru objenesis-1.2/org/objenesis/strategy/SerializingInstantiatorStrategy.java objenesis-1.2+full/org/objenesis/strategy/SerializingInstantiatorStrategy.java --- objenesis-1.2/org/objenesis/strategy/SerializingInstantiatorStrategy.java 2009-08-26 22:12:24.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/strategy/SerializingInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.strategy; - -import java.io.NotSerializableException; -import java.io.Serializable; - -import org.objenesis.ObjenesisException; -import org.objenesis.instantiator.ObjectInstantiator; -import org.objenesis.instantiator.basic.ObjectStreamClassInstantiator; -import org.objenesis.instantiator.gcj.GCJSerializationInstantiator; -import org.objenesis.instantiator.perc.PercSerializationInstantiator; -import org.objenesis.instantiator.sun.Sun13SerializationInstantiator; - -/** - * Guess the best serializing instantiator for a given class. The returned instantiator will - * instantiate classes like the genuine java serialization framework (the constructor of the first - * not serializable class will be called). Currently, the selection doesn't depend on the class. It - * relies on the - *

    - *
  • JVM version
  • - *
  • JVM vendor
  • - *
  • JVM vendor version
  • - *
- * However, instantiators are stateful and so dedicated to their class. - * - * @author Henri Tremblay - * @see ObjectInstantiator - */ -public class SerializingInstantiatorStrategy extends BaseInstantiatorStrategy { - - /** - * Return an {@link ObjectInstantiator} allowing to create instance following the java - * serialization framework specifications. - * - * @param type Class to instantiate - * @return The ObjectInstantiator for the class - */ - public ObjectInstantiator newInstantiatorOf(Class type) { - if(!Serializable.class.isAssignableFrom(type)) { - throw new ObjenesisException(new NotSerializableException(type+" not serializable")); - } - if(JVM_NAME.startsWith(SUN)) { - if(VM_VERSION.startsWith("1.3")) { - return new Sun13SerializationInstantiator(type); - } - } - else if(JVM_NAME.startsWith(GNU)) { - return new GCJSerializationInstantiator(type); - } - else if(JVM_NAME.startsWith(PERC)) { - return new PercSerializationInstantiator(type); - } - - return new ObjectStreamClassInstantiator(type); - } - -} diff -Nru objenesis-1.2/org/objenesis/strategy/StdInstantiatorStrategy.java objenesis-1.2+full/org/objenesis/strategy/StdInstantiatorStrategy.java --- objenesis-1.2/org/objenesis/strategy/StdInstantiatorStrategy.java 2009-08-26 22:12:24.000000000 +0000 +++ objenesis-1.2+full/org/objenesis/strategy/StdInstantiatorStrategy.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,87 +0,0 @@ -/** - * Copyright 2006-2009 the original author or authors. - * - * 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. - */ -package org.objenesis.strategy; - -import org.objenesis.instantiator.ObjectInstantiator; -import org.objenesis.instantiator.gcj.GCJInstantiator; -import org.objenesis.instantiator.jrockit.JRockit131Instantiator; -import org.objenesis.instantiator.jrockit.JRockitLegacyInstantiator; -import org.objenesis.instantiator.perc.PercInstantiator; -import org.objenesis.instantiator.sun.Sun13Instantiator; -import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator; - -/** - * Guess the best instantiator for a given class. The instantiator will instantiate the class - * without calling any constructor. Currently, the selection doesn't depend on the class. It relies - * on the - *
    - *
  • JVM version
  • - *
  • JVM vendor
  • - *
  • JVM vendor version
  • - *
- * However, instantiators are stateful and so dedicated to their class. - * - * @author Henri Tremblay - * @see ObjectInstantiator - */ -public class StdInstantiatorStrategy extends BaseInstantiatorStrategy { - - /** - * Return an {@link ObjectInstantiator} allowing to create instance without any constructor being - * called. - * - * @param type Class to instantiate - * @return The ObjectInstantiator for the class - */ - public ObjectInstantiator newInstantiatorOf(Class type) { - - if(JVM_NAME.startsWith(SUN)) { - if(VM_VERSION.startsWith("1.3")) { - return new Sun13Instantiator(type); - } - } - else if(JVM_NAME.startsWith(JROCKIT)) { - if(VM_VERSION.startsWith("1.3")) { - return new JRockit131Instantiator(type); - } - else if(VM_VERSION.startsWith("1.4")) { - // JRockit vendor version will be RXX where XX is the version - // Versions prior to 26 need special handling - // From R26 on, java.vm.version starts with R - if(!VENDOR_VERSION.startsWith("R")) { - // On R25.1 and R25.2, ReflectionFactory should work. Otherwise, we must use the - // Legacy instantiator. - if(VM_INFO == null || !VM_INFO.startsWith("R25.1") || !VM_INFO.startsWith("R25.2")) { - return new JRockitLegacyInstantiator(type); - } - } - } - } - else if(JVM_NAME.startsWith(GNU)) { - return new GCJInstantiator(type); - } - else if(JVM_NAME.startsWith(PERC)) { - return new PercInstantiator(type); - } - - // Fallback instantiator, should work with: - // - Java Hotspot version 1.4 and higher - // - JRockit 1.4-R26 and higher - // - IBM and Hitachi JVMs - // ... might works for others so we just give it a try - return new SunReflectionFactoryInstantiator(type); - } -} diff -Nru objenesis-1.2/pom.xml objenesis-1.2+full/pom.xml --- objenesis-1.2/pom.xml 2009-08-26 22:15:13.000000000 +0000 +++ objenesis-1.2+full/pom.xml 2009-08-26 21:12:00.000000000 +0000 @@ -18,72 +18,301 @@ 4.0.0 - - org.objenesis - objenesis-parent - 1.2 - .. - - objenesis - Objenesis - A library for instantiating Java objects - http://objenesis.googlecode.com/svn/docs/index.html + Objenesis parent project + org.objenesis + objenesis-parent + 1.2 + pom + 2006 - + + main + tck + + + + + Apache 2 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + Joe Walnes, Henri Tremblay, Leonardo Mesquita + + + + scm:svn:http://objenesis.googlecode.com/svn/trunk + scm:svn:https://objenesis.googlecode.com/svn/trunk + http://objenesis.googlecode.com/svn/trunk + + + + + joe + Joe Walnes + 0 + + + henri + Henri Tremblay + Ossia Conseil + http://www.ossia-conseil.com + +1 + + + leonardo + Leonardo Mesquita + -5 + + + + + + junit + junit + 3.8.2 + test + + + ${basedir}/src + + + + ${basedir}/src + + + **/*.java + + + + ${basedir}/test + + + + ${basedir}/test + + + **/*.java + + + - com.keyboardsamurais.maven - maven-timestamp-plugin - + maven-compiler-plugin + + 1.3 + 1.3 + + - com.google.code.maven-license-plugin - maven-license-plugin + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + maven-jar-plugin + + true + + true + false + + true + true + + + + + org.apache.maven.plugins - maven-remote-resources-plugin - + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + - org.apache.felix - maven-bundle-plugin + maven-site-plugin + false - - org.objenesis.* - org.objenesis.* - + ${basedir}/website + + + + maven-eclipse-plugin + 2.7 + + true + + + org.apache.maven.wagon + wagon-ssh-external + 1.0-beta-5 + + + + + + org.apache.felix + maven-bundle-plugin + 2.0.0 + + + bundle-manifest + prepare-package + + manifest + + + + + + com.keyboardsamurais.maven + maven-timestamp-plugin + 1.0 + + + year + + create + + + year + yyyy + + + + + + com.google.code.maven-license-plugin + maven-license-plugin + 1.4.0 + +
${basedir}/../header.txt
+ + + target/** + + src/org/objenesis/instantiator/jrockit/*.java + + dependency-reduced-pom.xml + + eclipse_config/** + + + ${project.inceptionYear} + ${year} + +
+ + + check + + check + + + +
+ + org.apache.maven.plugins + maven-remote-resources-plugin + 1.0 + + + + process + + + + org.apache:apache-jar-resource-bundle:1.3 + + + + + +
+
+ + + + org.codehaus.mojo + findbugs-maven-plugin + 2.1 + + + org.apache.maven.plugins + maven-pmd-plugin + 2.4 + + 1.3 + + + + + + + easymock-release + EasyMock Repository + scpexe://shell.sf.net/home/groups/e/ea/easymock/htdocs/maven/repository + + + easymock-snapshot + EasyMock Snapshot Repository + scpexe://shell.sf.net/home/groups/e/ea/easymock/htdocs/maven/repository-snapshot + + + - - release + + license - - - org.apache.maven.plugins - maven-assembly-plugin - - - assembly.xml - - - - - make-assembly - package - - single - - - - - + + + + com.google.code.maven-license-plugin + maven-license-plugin + + + format + generate-sources + + format + + + + + + + + + website + + website + +
diff -Nru objenesis-1.2/settings-example.xml objenesis-1.2+full/settings-example.xml --- objenesis-1.2/settings-example.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/settings-example.xml 2009-06-21 23:47:46.000000000 +0000 @@ -0,0 +1,28 @@ + + + + + + test + + true + + + c:\jdk1.3.1_19\bin\java.exe + c:\j2sdk1.4.2_12\bin\java.exe + c:\Arquivos de Programas\Java\jre1.5.0_10\bin\java.exe + c:\Arquivos de Programas\Java\jre1.6.0_13\bin\java.exe + c:\Arquivos de programas\JRockit\7.0SP6\1.3.1\bin\java.exe + c:\jrockit-j2sdk1.4.2_08\bin\java.exe + c:\jrrt-3.1.0-1.5.0\bin\java.exe + c:\jrrt-3.1.0-1.6.0\bin\java.exe + + + + diff -Nru objenesis-1.2/tck/pom.xml objenesis-1.2+full/tck/pom.xml --- objenesis-1.2/tck/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/pom.xml 2009-08-26 21:27:20.000000000 +0000 @@ -0,0 +1,277 @@ + + + + + + 4.0.0 + + org.objenesis + objenesis-parent + 1.2 + .. + + objenesis-tck + Objenesis TCK + + + + org.objenesis + objenesis + ${project.version} + + + + + + org.springframework.osgi + spring-osgi-test + 1.2.0 + test + + + org.springframework.osgi + spring-osgi-annotation + 1.2.0 + test + + + org.springframework.osgi + spring-osgi-extender + 1.2.0 + test + + + + + org.slf4j + com.springsource.slf4j.org.apache.commons.logging + 1.5.0 + test + + + org.slf4j + com.springsource.slf4j.api + 1.5.0 + test + + + org.slf4j + com.springsource.slf4j.log4j + 1.5.0 + test + + + log4j + log4j + + + com.springsource.org.apache.log4j + org.apache.log4j + + + + + org.springframework.osgi + log4j.osgi + 1.2.15-SNAPSHOT + test + + + + + org.eclipse.osgi + org.eclipse.osgi + 3.2.2 + test + + + + + + + com.keyboardsamurais.maven + maven-timestamp-plugin + + + com.google.code.maven-license-plugin + maven-license-plugin + + + org.apache.maven.plugins + maven-remote-resources-plugin + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.objenesis.tck.Main + + + + + + org.apache.maven.plugins + maven-shade-plugin + 1.2.1 + + + package + + shade + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + http://objenesis.googlecode.com/svn/docs/apidocs/ + + + + + + + + + jvm-test + + + + maven-surefire-plugin + + + Sun 1.3 + + test + + test + + ${sun_jdk1_3.jvm} + + + + Sun 1.4 + + test + + test + + ${sun_jdk1_4.jvm} + + + + Sun 1.5 + + test + + test + + ${sun_jdk1_5.jvm} + + + + Sun 1.6 + + test + + test + + ${sun_jdk1_6.jvm} + + + + JRockit for Java 1.3 + + test + + test + + ${jrockit1_3.jvm} + + + + JRockit for Java 1.4 + + test + + test + + ${jrockit1_4.jvm} + + + + JRockit for Java 1.5 + + test + + test + + ${jrockit1_5.jvm} + + + + JRockit for Java 1.6 + + test + + test + + ${jrockit1_6.jvm} + + + + + + + + + + release + + + + org.codehaus.mojo + exec-maven-plugin + false + + java + + -jar + ${project.build.directory}\${project.build.finalName}.jar + + + + + test-release + integration-test + + exec + + + + + + + + + + diff -Nru objenesis-1.2/tck/.settings/org.eclipse.core.resources.prefs objenesis-1.2+full/tck/.settings/org.eclipse.core.resources.prefs --- objenesis-1.2/tck/.settings/org.eclipse.core.resources.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/.settings/org.eclipse.core.resources.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,3 @@ +#Mon Feb 12 00:06:57 CET 2007 +eclipse.preferences.version=1 +encoding/=ISO-8859-1 diff -Nru objenesis-1.2/tck/.settings/org.eclipse.jdt.core.prefs objenesis-1.2+full/tck/.settings/org.eclipse.jdt.core.prefs --- objenesis-1.2/tck/.settings/org.eclipse.jdt.core.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/.settings/org.eclipse.jdt.core.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,259 @@ +#Sun Feb 11 23:43:02 CET 2007 +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.3 +org.eclipse.jdt.core.compiler.compliance=1.3 +org.eclipse.jdt.core.compiler.source=1.3 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines=true +org.eclipse.jdt.core.formatter.comment.format_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert +org.eclipse.jdt.core.formatter.comment.line_length=100 +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=3 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=100 +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=3 +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false diff -Nru objenesis-1.2/tck/.settings/org.eclipse.jdt.ui.prefs objenesis-1.2+full/tck/.settings/org.eclipse.jdt.ui.prefs --- objenesis-1.2/tck/.settings/org.eclipse.jdt.ui.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/.settings/org.eclipse.jdt.ui.prefs 2007-02-11 23:16:19.000000000 +0000 @@ -0,0 +1,10 @@ +#Sun Feb 11 23:43:16 CET 2007 +eclipse.preferences.version=1 +formatter_profile=_Objenesis +formatter_settings_version=10 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.javadoc=false +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.overrideannotation=true +org.eclipse.jdt.ui.text.custom_code_templates= diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/CandidateLoader.java objenesis-1.2+full/tck/src/org/objenesis/tck/CandidateLoader.java --- objenesis-1.2/tck/src/org/objenesis/tck/CandidateLoader.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/CandidateLoader.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,129 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.util.Properties; + +/** + * Loads a set of candidate classes from a properties file into the TCK.

The properties file + * takes the form of candidateClassName=shortDescription. + * + * @author Joe Walnes + * @see TCK + */ +public class CandidateLoader { + + private final TCK tck; + private final ClassLoader classloader; + private final ErrorHandler errorHandler; + + /** + * Handler for reporting errors from the CandidateLoader. + */ + public static interface ErrorHandler { + /** + * Called whenever, trying to retrieve a candidate class from its name, a + * ClassNotFoundException is thrown + * + * @param name Candidate class name + */ + void classNotFound(String name); + } + + /** + * Error handler that logs errors to a text stream. + */ + public static class LoggingErrorHandler implements CandidateLoader.ErrorHandler { + + private final PrintStream out; + + /** + * @param out Stream in which to log + */ + public LoggingErrorHandler(PrintStream out) { + this.out = out; + } + + public void classNotFound(String name) { + out.println("Class not found : " + name); + } + + } + + /** + * @param tck TCK that will use the candidates + * @param classloader ClassLoader from which candidates classes are loaded + * @param errorHandler Handler called in case of error + */ + public CandidateLoader(TCK tck, ClassLoader classloader, ErrorHandler errorHandler) { + this.tck = tck; + this.classloader = classloader; + this.errorHandler = errorHandler; + } + + /** + * @param inputStream Stream containing the properties + * @throws IOException If something goes wrong while reading the stream + */ + public void loadFrom(InputStream inputStream) throws IOException { + // Properties contains a convenient key=value parser, however it stores + // the entries in a Hashtable which loses the original order. + // So, we create a special Properties instance that writes its + // entries directly to the TCK (which retains order). + Properties properties = new Properties() { + private static final long serialVersionUID = 1L; + public Object put(Object key, Object value) { + handlePropertyEntry((String) key, (String) value); + return null; + } + }; + properties.load(inputStream); + } + + /** + * Load a candidate property file + * + * @param cls Class on which getResourceAsStream is called + * @param resource File name + * @throws IOException If there's problem reading the file + */ + public void loadFromResource(Class cls, String resource) throws IOException { + InputStream candidatesConfig = cls.getResourceAsStream(resource); + if(candidatesConfig == null) { + throw new IOException("Resource '" + resource + "' not found relative to " + cls.getName()); + } + try { + loadFrom(candidatesConfig); + } + finally { + candidatesConfig.close(); + } + } + + private void handlePropertyEntry(String key, String value) { + try { + Class candidate = Class.forName(key, true, classloader); + tck.registerCandidate(candidate, value); + } + catch(ClassNotFoundException e) { + errorHandler.classNotFound(key); + } + } + +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/candidates.properties objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/candidates.properties --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/candidates.properties 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/candidates.properties 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,39 @@ +# +# Copyright 2006-2009 the original author or authors. +# +# 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. +# +# List of candidate classes to attempt to instantiate in the Objenesis TCK. + +# Different visibilities of constructor. +org.objenesis.tck.candidates.NoConstructor = No constructor +org.objenesis.tck.candidates.SerializableNoConstructor = No constructor (serializable) +org.objenesis.tck.candidates.DefaultPublicConstructor = Default public constructor +org.objenesis.tck.candidates.SerializableDefaultPublicConstructor = Default public constructor (serializable) +org.objenesis.tck.candidates.DefaultProtectedConstructor = Default protected constructor +org.objenesis.tck.candidates.SerializableDefaultProtectedConstructor = Default protected constructor (serializable) +org.objenesis.tck.candidates.DefaultPackageConstructor = Default package constructor +org.objenesis.tck.candidates.SerializableDefaultPackageConstructor = Default package constructor (serializable) +org.objenesis.tck.candidates.DefaultPrivateConstructor = Default private constructor +org.objenesis.tck.candidates.SerializableDefaultPrivateConstructor = Default private constructor (serializable) +org.objenesis.tck.candidates.SerializableWithAncestorThrowingException = Serializable with ancestor throwing exception +org.objenesis.tck.candidates.SerializableReplacer = Serializable replacing with another class +org.objenesis.tck.candidates.SerializableResolver = Serializable resolving to another class + +# Constructors that work with arguments passed in. +org.objenesis.tck.candidates.ConstructorThrowingException = Constructor throwing exception +org.objenesis.tck.candidates.SerializableConstructorThrowingException = Constructor throwing exception (serializable) +org.objenesis.tck.candidates.ConstructorWithArguments = Constructor with arguments +org.objenesis.tck.candidates.SerializableConstructorWithArguments = Constructor with arguments (serializable) +org.objenesis.tck.candidates.ConstructorWithMandatoryArguments = Constructor with mandatory arguments +org.objenesis.tck.candidates.SerializableConstructorWithMandatoryArguments = Constructor with mandatory arguments (serializable) diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorThrowingException.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,27 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class ConstructorThrowingException { + + public ConstructorThrowingException() { + throw new IllegalArgumentException("Constructor throwing an exception"); + } + +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorWithArguments.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,34 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class ConstructorWithArguments { + + private final String something; + private final int another; + + public ConstructorWithArguments(String something, int another) { + this.something = something; + this.another = another; + } + + public String toString() { + return something + another; + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/ConstructorWithMandatoryArguments.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,28 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class ConstructorWithMandatoryArguments { + + public ConstructorWithMandatoryArguments(String something) { + if(something == null) { + throw new IllegalArgumentException("Need arguments"); + } + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPackageConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,26 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class DefaultPackageConstructor { + + DefaultPackageConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPrivateConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,26 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class DefaultPrivateConstructor { + + private DefaultPrivateConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultProtectedConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,26 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class DefaultProtectedConstructor { + + protected DefaultProtectedConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/DefaultPublicConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,26 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class DefaultPublicConstructor { + + public DefaultPublicConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/NoConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/NoConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/NoConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/NoConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,22 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +/** + * @author Joe Walnes + */ +public class NoConstructor { +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/serializable-candidates.properties objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/serializable-candidates.properties --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/serializable-candidates.properties 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/serializable-candidates.properties 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +# +# Copyright 2006-2009 the original author or authors. +# +# 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. +# +# List of candidate classes to attempt to instantiate in the Objenesis TCK. + +# Different visibilities of constructor. +org.objenesis.tck.candidates.SerializableNoConstructor = No constructor (serializable) +org.objenesis.tck.candidates.SerializableDefaultPublicConstructor = Default public constructor (serializable) +org.objenesis.tck.candidates.SerializableDefaultProtectedConstructor = Default protected constructor (serializable) +org.objenesis.tck.candidates.SerializableDefaultPackageConstructor = Default package constructor (serializable) +org.objenesis.tck.candidates.SerializableDefaultPrivateConstructor = Default private constructor (serializable) +org.objenesis.tck.candidates.SerializableReplacer = Serializable replacing with another class +org.objenesis.tck.candidates.SerializableResolver = Serializable resolving to another class + +# Constructors that work with arguments passed in. +org.objenesis.tck.candidates.SerializableConstructorThrowingException = Constructor throwing exception (serializable) +org.objenesis.tck.candidates.SerializableConstructorWithArguments = Constructor with arguments (serializable) +org.objenesis.tck.candidates.SerializableConstructorWithMandatoryArguments = Constructor with mandatory arguments (serializable) diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorThrowingException.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,31 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableConstructorThrowingException implements Serializable { + + private static final long serialVersionUID = 1L; + + public SerializableConstructorThrowingException() { + throw new IllegalArgumentException("Constructor throwing an exception"); + } + +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithArguments.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,38 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableConstructorWithArguments implements Serializable { + + private static final long serialVersionUID = 1L; + + private final String something; + private final int another; + + public SerializableConstructorWithArguments(String something, int another) { + this.something = something; + this.another = another; + } + + public String toString() { + return something + another; + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableConstructorWithMandatoryArguments.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,32 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableConstructorWithMandatoryArguments implements Serializable { + + private static final long serialVersionUID = 1L; + + public SerializableConstructorWithMandatoryArguments(String something) { + if(something == null) { + throw new IllegalArgumentException("Need arguments"); + } + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPackageConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableDefaultPackageConstructor implements Serializable { + + private static final long serialVersionUID = 1L; + + SerializableDefaultPackageConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPrivateConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableDefaultPrivateConstructor implements Serializable { + + private static final long serialVersionUID = 1L; + + private SerializableDefaultPrivateConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultProtectedConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableDefaultProtectedConstructor implements Serializable { + + private static final long serialVersionUID = 1L; + + protected SerializableDefaultProtectedConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableDefaultPublicConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableDefaultPublicConstructor implements Serializable { + + private static final long serialVersionUID = 1L; + + public SerializableDefaultPublicConstructor() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableNoConstructor.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,25 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableNoConstructor implements Serializable { + private static final long serialVersionUID = 1L; +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableReplacer.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableReplacer implements Serializable { + + private static final long serialVersionUID = 1L; + + protected Object writeReplace() { + return new SerializableResolver(); + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableResolver.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableResolver.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableResolver.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableResolver.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,30 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableResolver implements Serializable { + + private static final long serialVersionUID = 1L; + + protected Object readResolve() { + return new SerializableReplacer(); + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java --- objenesis-1.2/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/candidates/SerializableWithAncestorThrowingException.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,31 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck.candidates; + +import java.io.Serializable; + +/** + * @author Joe Walnes + */ +public class SerializableWithAncestorThrowingException extends ConstructorThrowingException + implements Serializable { + + private static final long serialVersionUID = 1L; + + public SerializableWithAncestorThrowingException() { + + } +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/Main.java objenesis-1.2+full/tck/src/org/objenesis/tck/Main.java --- objenesis-1.2/tck/src/org/objenesis/tck/Main.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/Main.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,104 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.IOException; +import java.io.Serializable; + +import org.objenesis.Objenesis; +import org.objenesis.ObjenesisSerializer; +import org.objenesis.ObjenesisStd; + +/** + * Command line launcher for Technology Compatibility Kit (TCK). + * + * @author Joe Walnes + * @see TCK + */ +public class Main { + + private static class MockSuperClass { + private final boolean superConstructorCalled; + + public MockSuperClass() { + superConstructorCalled = true; + } + + public boolean isSuperConstructorCalled() { + return superConstructorCalled; + } + } + + private static class MockClass extends MockSuperClass implements Serializable { + private static final long serialVersionUID = 1L; + + private final boolean constructorCalled; + + public MockClass() { + constructorCalled = true; + } + + public boolean isConstructorCalled() { + return constructorCalled; + } + } + + /** + * Main class of the TCK. Can also be called as a normal method from an application server. + * + * @param args No parameters are required + * @throws IOException When the TCK fails to read properties' files. + */ + public static void main(String[] args) throws IOException { + + TextReporter reporter = new TextReporter(System.out, System.err); + + runTest(new ObjenesisStd(), reporter, "Objenesis std", "candidates/candidates.properties"); + runTest(new ObjenesisSerializer(), reporter, "Objenesis serializer", + "candidates/serializable-candidates.properties"); + + boolean result = runParentConstructorTest(); + + reporter.printResult(result); + } + + private static boolean runParentConstructorTest() { + try { + Object result = new ObjenesisSerializer().newInstance(MockClass.class); + MockClass mockObject = (MockClass) result; + return mockObject.isSuperConstructorCalled() && !mockObject.isConstructorCalled(); + } + catch(Exception e) { + System.err.println("--- Not serializable parent constructor called ---"); + e.printStackTrace(System.err); + return false; + } + } + + private static void runTest(Objenesis objenesis, Reporter reporter, String description, + String candidates) throws IOException { + TCK tck = new TCK(); + tck.registerObjenesisInstance(objenesis, description); + + CandidateLoader candidateLoader = new CandidateLoader(tck, Main.class.getClassLoader(), + new CandidateLoader.LoggingErrorHandler(System.err)); + + candidateLoader.loadFromResource(Main.class, candidates); + + tck.runTests(reporter); + } + +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/Reporter.java objenesis-1.2+full/tck/src/org/objenesis/tck/Reporter.java --- objenesis-1.2/tck/src/org/objenesis/tck/Reporter.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/Reporter.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,80 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.util.Collection; + +/** + * Reports results from the TCK back to the user. + *

+ * The sequence these methods are called is described below: + *

+ * + *
+ * startTests(startObjenesis(result | exception) * endObjenesis) * endTests
+ * 
+ * + * @author Joe Walnes + * @see TCK + * @see TextReporter + */ +public interface Reporter { + + /** + * Report that the tests are starting. Provides information that is useful to be reported. + * + * @param platformDescription Description the platform being run on (i.e. JVM version, vendor, + * etc). + * @param allCandidates Descriptions (String) of all candidates being used in tests. + * @param allObjenesisInstances Descriptions of all Objenesis instances being used in tests. + */ + void startTests(String platformDescription, Collection allCandidates, + Collection allObjenesisInstances); + + /** + * Report that a test between a candidate and an objenesis instance if about to start. + * + * @param candidateDescription Description of the candidate class. + * @param objenesisDescription Description of the objenesis instance. + */ + void startTest(String candidateDescription, String objenesisDescription); + + /** + * Report details about what happened when an Objenesis instance tried to instantiate the current + * candidate. + * + * @param instantiatedObject Whether the ObjectInstantiator successfully instantiated the + * candidate class. + */ + void result(boolean instantiatedObject); + + /** + * Report that something bad happened during the test. + * + * @param exception Exception thrown by instantiator. + */ + void exception(Exception exception); + + /** + * Report that tests have been completed for a particular Objenesis instance and candidate. + */ + void endTest(); + + /** + * Report that all tests have finished. Nothing will be called after this method. + */ + void endTests(); +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/TCK.java objenesis-1.2+full/tck/src/org/objenesis/tck/TCK.java --- objenesis-1.2/tck/src/org/objenesis/tck/TCK.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/TCK.java 2009-08-26 21:27:20.000000000 +0000 @@ -0,0 +1,143 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.objenesis.Objenesis; + +/** + * Technology Compatibility Kit (TCK) for {@link Objenesis}s. + *

+ * This TCK accepts a set of candidate classes (class it attempts to instantiate) and a set of + * Objenesis implementations. It then tries instantiating every candidate with every Objenesis + * implementations, reporting the results to a {@link Reporter}. + *

Example usage

+ * + *
+ * TCK tck = new TCK();
+ * // register candidate classes.
+ * tck.registerCandidate(SomeClass.class, "A basic class");
+ * tck.registerCandidate(SomeEvil.class, "Something evil");
+ * tck.registerCandidate(NotEvil.class, "Something nice");
+ * // register Objenesis instances.
+ * tck.registerObjenesisInstance(new ObjenesisStd(), "Objenesis");
+ * tck.registerObjenesisInstance(new ObjenesisSerializaer(), "Objenesis for serialization");
+ * // go!
+ * Reporter reporter = new TextReporter(System.out, System.err);
+ * tck.runTests(reporter);
+ * 
+ * + * @author Joe Walnes + * @see org.objenesis.instantiator.ObjectInstantiator + * @see Reporter + * @see Main + */ +public class TCK { + + private final List objenesisInstances = new ArrayList(); + private final List candidates = new ArrayList(); + private final Map descriptions = new HashMap(); + + /** + * Register a candidate class to attempt to instantiate. + * + * @param candidateClass Class to attempt to instantiate + * @param description Description of the class + */ + public void registerCandidate(Class candidateClass, String description) { + candidates.add(candidateClass); + descriptions.put(candidateClass, description); + } + + /** + * Register an Objenesis instance to use when attempting to instantiate a class. + * + * @param objenesis Tested Objenesis instance + * @param description Description of the Objenesis instance + */ + public void registerObjenesisInstance(Objenesis objenesis, String description) { + objenesisInstances.add(objenesis); + descriptions.put(objenesis, description); + } + + /** + * Run all TCK tests. + * + * @param reporter Where to report the results of the test to. + */ + public void runTests(Reporter reporter) { + reporter.startTests(describePlatform(), findAllDescriptions(candidates, descriptions), + findAllDescriptions(objenesisInstances, descriptions)); + + for(Iterator i = candidates.iterator(); i.hasNext();) { + Class candidateClass = (Class) i.next(); + String candidateDescription = (String) descriptions.get(candidateClass); + + for(Iterator j = objenesisInstances.iterator(); j.hasNext();) { + Objenesis objenesis = (Objenesis) j.next(); + + String objenesisDescription = (String) descriptions.get(objenesis); + + reporter.startTest(candidateDescription, objenesisDescription); + + runTest(reporter, candidateClass, objenesis, candidateDescription); + + reporter.endTest(); + } + } + reporter.endTests(); + } + + private void runTest(Reporter reporter, Class candidate, Objenesis objenesis, + String candidateDescription) { + try { + Object instance = objenesis.newInstance(candidate); + boolean success = instance != null && instance.getClass() == candidate; + reporter.result(success); + } + catch(Exception e) { + reporter.exception(e); + } + } + + private Collection findAllDescriptions(List keys, Map descriptions) { + List results = new ArrayList(keys.size()); + for(int i = 0; i < keys.size(); i++) { + results.add(descriptions.get(keys.get(i))); + } + return results; + } + + /** + * Describes the platform. Outputs Java version and vendor. To change this behavior, override + * this method. + * + * @return Description of the current platform + */ + protected String describePlatform() { + return "Java " + System.getProperty("java.specification.version") + " (" + + System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " " + + System.getProperty("java.vm.version") + " " + System.getProperty("java.runtime.version") + + ")"; + } + +} diff -Nru objenesis-1.2/tck/src/org/objenesis/tck/TextReporter.java objenesis-1.2+full/tck/src/org/objenesis/tck/TextReporter.java --- objenesis-1.2/tck/src/org/objenesis/tck/TextReporter.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/src/org/objenesis/tck/TextReporter.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,239 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * Reports results from TCK as tabulated text, suitable for dumping to the console or a file and + * being read by a human. If can be reused to provide a summary reports of different candidates as + * long as the same objenesisDescription is not used twice. + * + * @author Joe Walnes + * @author Henri Tremblay + * @see TCK + * @see Reporter + */ +public class TextReporter implements Reporter { + + private static class Result { + + String objenesisDescription; + + String candidateDescription; + + boolean result; + + Exception exception; + + /** + * @param objenesisDescription Description of the tested Objenesis instance + * @param candidateDescription Description of the tested candidate + * @param result If the test is successful or not + * @param exception Exception that might have occured during the test + */ + public Result(String objenesisDescription, String candidateDescription, boolean result, + Exception exception) { + this.objenesisDescription = objenesisDescription; + this.candidateDescription = candidateDescription; + this.result = result; + this.exception = exception; + } + } + + private final PrintStream summary; + + private final PrintStream log; + + private long startTime; + + private long totalTime = 0; + + private int errorCount = 0; + + private SortedSet allCandidates = new TreeSet(); + + private SortedSet allInstantiators = new TreeSet(); + + private String currentObjenesis; + + private String currentCandidate; + + private Map objenesisResults = new HashMap(); + + private String platformDescription; + + /** + * @param summary Output of main report. + * @param log Any additional information, useful for diagnostics. + */ + public TextReporter(PrintStream summary, PrintStream log) { + this.summary = summary; + this.log = log; + } + + public void startTests(String platformDescription, Collection allCandidates, + Collection allInstantiators) { + + // HT: in case the same reporter is reused, I'm guessing that it will + // always be the + // same platform + this.platformDescription = platformDescription; + this.allCandidates.addAll(allCandidates); + this.allInstantiators.addAll(allInstantiators); + + for(Iterator it = allInstantiators.iterator(); it.hasNext();) { + objenesisResults.put(it.next(), new HashMap()); + } + + startTime = System.currentTimeMillis(); + } + + public void startTest(String candidateDescription, String objenesisDescription) { + currentCandidate = candidateDescription; + currentObjenesis = objenesisDescription; + } + + public void result(boolean instantiatedObject) { + if(!instantiatedObject) { + errorCount++; + } + ((Map) objenesisResults.get(currentObjenesis)).put(currentCandidate, new Result( + currentObjenesis, currentCandidate, instantiatedObject, null)); + } + + public void exception(Exception exception) { + + errorCount++; + + ((Map) objenesisResults.get(currentObjenesis)).put(currentCandidate, new Result( + currentObjenesis, currentCandidate, false, exception)); + } + + public void endTest() { + } + + public void endTests() { + totalTime += System.currentTimeMillis() - startTime; + } + + /** + * Print the final summary report + */ + public void printResult(boolean parentConstructorTest) { + // Platform + summary.println("Running TCK on platform: " + platformDescription); + summary.println(); + + summary.println("Not serializable parent constructor called: " + + (parentConstructorTest ? 'Y' : 'N')); + summary.println(); + + if(!parentConstructorTest) { + errorCount++; + } + + int maxObjenesisWidth = lengthOfLongestStringIn(allInstantiators); + int maxCandidateWidth = lengthOfLongestStringIn(allCandidates); + + // Header + summary.print(pad("", maxCandidateWidth) + ' '); + for(Iterator it = allInstantiators.iterator(); it.hasNext();) { + String desc = (String) it.next(); + summary.print(pad(desc, maxObjenesisWidth) + ' '); + } + summary.println(); + + List exceptions = new ArrayList(); + + // Candidates (and keep the exceptions meanwhile) + for(Iterator it = allCandidates.iterator(); it.hasNext();) { + String candidateDesc = (String) it.next(); + summary.print(pad(candidateDesc, maxCandidateWidth) + ' '); + + for(Iterator itInst = allInstantiators.iterator(); itInst.hasNext();) { + String instDesc = (String) itInst.next(); + Result result = (Result) ((Map) objenesisResults.get(instDesc)).get(candidateDesc); + if(result == null) { + summary.print(pad("N/A", maxObjenesisWidth) + " "); + } + else { + summary.print(pad(result.result ? "Y" : "n", maxObjenesisWidth) + " "); + + if(result.exception != null) { + exceptions.add(result); + } + } + } + summary.println(); + } + + summary.println(); + + // Final + if(errorCount != 0) { + + for(Iterator it = exceptions.iterator(); it.hasNext();) { + Result element = (Result) it.next(); + log.println("--- Candidate '" + element.candidateDescription + "', Instantiator '" + + element.objenesisDescription + "' ---"); + element.exception.printStackTrace(log); + log.println(); + } + + log.println(); + + summary.println("--- FAILED: " + errorCount + " error(s) occured ---"); + } + else { + summary.println("--- SUCCESSFUL: TCK tests passed without errors in " + totalTime + " ms"); + } + + summary.println(); + } + + private String pad(String text, int width) { + if(text.length() == width) { + return text; + } + else if(text.length() > width) { + return text.substring(0, width); + } + else { + StringBuffer padded = new StringBuffer(text); + while(padded.length() < width) { + padded.append(' '); + } + return padded.toString(); + } + } + + private int lengthOfLongestStringIn(Collection descriptions) { + int result = 0; + for(Iterator it = descriptions.iterator(); it.hasNext();) { + result = Math.max(result, ((String) it.next()).length()); + } + return result; + } +} diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/CandidateLoaderTest.java objenesis-1.2+full/tck/test/org/objenesis/tck/CandidateLoaderTest.java --- objenesis-1.2/tck/test/org/objenesis/tck/CandidateLoaderTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/CandidateLoaderTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,110 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import junit.framework.TestCase; + +/** + * @author Joe Walnes + */ +public class CandidateLoaderTest extends TestCase { + + private StringBuffer recordedEvents; + private CandidateLoader candidateLoader; + + protected void setUp() throws Exception { + super.setUp(); + + recordedEvents = new StringBuffer(); + TCK tck = new TCK() { + public void registerCandidate(Class candidateClass, String description) { + recordedEvents.append("registerCandidate('").append(candidateClass).append("', '") + .append(description).append("')\n"); + } + }; + CandidateLoader.ErrorHandler errorHandler = new CandidateLoader.ErrorHandler() { + public void classNotFound(String name) { + recordedEvents.append("classNotFound('").append(name).append("')\n"); + } + }; + + candidateLoader = new CandidateLoader(tck, getClass().getClassLoader(), errorHandler); + } + + public void testReadsClassesAndDescriptionsFromPropertiesFile() throws IOException { + String input = "" + "org.objenesis.tck.CandidateLoaderTest$A = A candidate\n" + "\n" + + "# a comment and some whitespace\n" + "\n" + + "org.objenesis.tck.CandidateLoaderTest$B = B candidate\n" + + "org.objenesis.tck.CandidateLoaderTest$C = C candidate\n"; + + candidateLoader.loadFrom(new ByteArrayInputStream(input.getBytes())); + + assertEquals("" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$A', 'A candidate')\n" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$B', 'B candidate')\n" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$C', 'C candidate')\n", + recordedEvents.toString()); + } + + public void testReportsMissingClassesToErrorHandler() throws IOException { + String input = "" + "org.objenesis.tck.CandidateLoaderTest$A = A candidate\n" + + "org.objenesis.tck.CandidateLoaderTest$NonExistant = Dodgy candidate\n" + + "org.objenesis.tck.CandidateLoaderTest$C = C candidate\n"; + + candidateLoader.loadFrom(new ByteArrayInputStream(input.getBytes())); + + assertEquals("" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$A', 'A candidate')\n" + + "classNotFound('org.objenesis.tck.CandidateLoaderTest$NonExistant')\n" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$C', 'C candidate')\n", + recordedEvents.toString()); + } + + public void testLoadsFromResourceInClassPath() throws IOException { + // See CandidateLoaderTest-sample.properties. + + candidateLoader.loadFromResource(getClass(), "CandidateLoaderTest-sample.properties"); + + assertEquals("" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$A', 'A candidate')\n" + + "registerCandidate('class org.objenesis.tck.CandidateLoaderTest$B', 'B candidate')\n", + recordedEvents.toString()); + } + + public void testThrowsIOExceptionIfResourceNotInClassPath() throws IOException { + try { + candidateLoader.loadFromResource(getClass(), "Blatently-Bogus.properties"); + fail("Expected exception"); + } + catch(IOException expectedException) { + // Good! + } + } + + // Sample classes. + + public static class A { + } + + public static class B { + } + + public static class C { + } +} diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/CandidateLoaderTest-sample.properties objenesis-1.2+full/tck/test/org/objenesis/tck/CandidateLoaderTest-sample.properties --- objenesis-1.2/tck/test/org/objenesis/tck/CandidateLoaderTest-sample.properties 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/CandidateLoaderTest-sample.properties 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,19 @@ +# +# Copyright 2006-2009 the original author or authors. +# +# 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. +# +# See CandidateLoaderTest.java + +org.objenesis.tck.CandidateLoaderTest$A = A candidate +org.objenesis.tck.CandidateLoaderTest$B = B candidate \ No newline at end of file diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/ObjenesisTest.java objenesis-1.2+full/tck/test/org/objenesis/tck/ObjenesisTest.java --- objenesis-1.2/tck/test/org/objenesis/tck/ObjenesisTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/ObjenesisTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,140 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.io.Serializable; +import java.util.Collection; + +import junit.framework.TestCase; + +import org.objenesis.ObjenesisSerializer; +import org.objenesis.ObjenesisStd; + +/** + * Integration test for Objenesis. Should pass successfully on every supported JVM for all Objenesis + * interface implementation. + * + * @author Henri Tremblay + */ +public class ObjenesisTest extends TestCase { + + public static class ErrorHandler implements CandidateLoader.ErrorHandler { + public void classNotFound(String name) { + fail("Class not found : " + name); + } + } + + public static class JUnitReporter implements Reporter { + + private String currentObjenesis; + + private String currentCandidate; + + public void startTests(String platformDescription, Collection allCandidates, + Collection allInstantiators) { + } + + public void startTest(String candidateDescription, String objenesisDescription) { + currentCandidate = candidateDescription; + currentObjenesis = objenesisDescription; + } + + public void endObjenesis(String description) { + } + + public void endTests() { + } + + public void exception(Exception exception) { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + PrintStream out = new PrintStream(buffer); + out.println("Exception when instantiating " + currentCandidate + " with " + + currentObjenesis + ": "); + exception.printStackTrace(out); + fail(buffer.toString()); + } + + public void result(boolean instantiatedObject) { + assertTrue("Instantiating " + currentCandidate + " with " + currentObjenesis + " failed", + instantiatedObject); + } + + public void endTest() { + } + } + + static class MockSuperClass { + private final boolean superConstructorCalled; + public MockSuperClass() { + superConstructorCalled = true; + } + public boolean isSuperConstructorCalled() { + return superConstructorCalled; + } + } + + static class MockClass extends MockSuperClass implements Serializable { + private static final long serialVersionUID = 1L; + private final boolean constructorCalled; + public MockClass() { + super(); + constructorCalled = true; + } + public boolean isConstructorCalled() { + return constructorCalled; + } + } + + private TCK tck = null; + + private CandidateLoader candidateLoader = null; + + protected void setUp() throws Exception { + super.setUp(); + + tck = new TCK(); + + candidateLoader = new CandidateLoader(tck, getClass().getClassLoader(), new ErrorHandler()); + } + + protected void tearDown() throws Exception { + candidateLoader = null; + tck = null; + super.tearDown(); + } + + public void testObjenesisStd() throws Exception { + candidateLoader.loadFromResource(getClass(), "candidates/candidates.properties"); + tck.registerObjenesisInstance(new ObjenesisStd(), "Objenesis standard"); + tck.runTests(new JUnitReporter()); + } + + public void testObjenesisSerializer() throws Exception { + candidateLoader.loadFromResource(getClass(), "candidates/serializable-candidates.properties"); + tck.registerObjenesisInstance(new ObjenesisSerializer(), "Objenesis serializer"); + tck.runTests(new JUnitReporter()); + } + + public void testObjenesisSerializerParentConstructorCalled() throws Exception { + Object result = new ObjenesisSerializer().newInstance(MockClass.class); + assertEquals(MockClass.class, result.getClass()); + MockClass mockObject = (MockClass) result; + assertTrue(mockObject.isSuperConstructorCalled()); + assertFalse(mockObject.isConstructorCalled()); + } +} diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/OsgiTest.java objenesis-1.2+full/tck/test/org/objenesis/tck/OsgiTest.java --- objenesis-1.2/tck/test/org/objenesis/tck/OsgiTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/OsgiTest.java 2009-08-23 23:16:29.000000000 +0000 @@ -0,0 +1,61 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.IOException; +import java.io.Serializable; + +import org.objenesis.Objenesis; +import org.objenesis.ObjenesisHelper; +import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests; + +/** + * @author Henri Tremblay + */ +public class OsgiTest extends AbstractConfigurableBundleCreatorTests implements Serializable { + + private static final long serialVersionUID = 1L; + + protected String[] getTestBundlesNames() { + final String version = Objenesis.class.getPackage() + .getImplementationVersion(); + + return new String[] {"org.objenesis, objenesis, " + version}; + } + + // protected Manifest getManifest() { + // Manifest mf = super.getManifest(); + // + // String imports = mf.getMainAttributes().getValue( + // Constants.IMPORT_PACKAGE); + // imports = imports.replace("org.easymock.internal,", + // "org.easymock.internal;poweruser=true,"); + // imports = imports.replace("org.easymock.internal.matchers,", + // "org.easymock.internal.matchers;poweruser=true,"); + // + // mf.getMainAttributes().putValue(Constants.IMPORT_PACKAGE, imports); + // + // return mf; + // } + + public void testCanInstantiate() throws IOException { + assertSame(OsgiTest.class, ObjenesisHelper.newInstance(getClass()).getClass()); + } + + public void testCanInstantiateSerialize() throws IOException { + assertSame(OsgiTest.class, ObjenesisHelper.newSerializableInstance(getClass()).getClass()); + } +} diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/TCKTest.java objenesis-1.2+full/tck/test/org/objenesis/tck/TCKTest.java --- objenesis-1.2/tck/test/org/objenesis/tck/TCKTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/TCKTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,163 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.util.Collection; + +import junit.framework.TestCase; + +import org.objenesis.Objenesis; +import org.objenesis.instantiator.ObjectInstantiator; + +/** + * @author Joe Walnes + * @author Henri Tremblay + */ +public class TCKTest extends TestCase { + + public static class StubbedInstantiator1 implements Objenesis { + public Object newInstance(Class clazz) { + return null; + } + + public ObjectInstantiator getInstantiatorOf(Class clazz) { + return null; + } + } + + public static class StubbedInstantiator2 implements Objenesis { + public Object newInstance(Class clazz) { + return null; + } + + public ObjectInstantiator getInstantiatorOf(Class clazz) { + return null; + } + } + + public void testReportsAllCandidatesAndInstantiatorCombinationsToReporter() { + // Given... a TCK with some candidate classes: A, B and C. + TCK tck = new TCK(); + + tck.registerCandidate(CandidateA.class, "Candidate A"); + tck.registerCandidate(CandidateB.class, "Candidate B"); + tck.registerCandidate(CandidateC.class, "Candidate C"); + + // And... two ObjectInstantiators registered + tck.registerObjenesisInstance(new StubbedInstantiator1(), "Instantiator1"); + tck.registerObjenesisInstance(new StubbedInstantiator2(), "Instantiator2"); + + // When... the TCK tests are run + Reporter reporter = new RecordingReporter(); + tck.runTests(reporter); + + // Expect... the reporter to have received a sequence of calls + // notifying it of what the TCK is doing. + assertEquals("" + "startTests()\n" + "startTest('Candidate A', 'Instantiator1')\n" + + "result(false)\n" + "endTest()\n" + "startTest('Candidate A', 'Instantiator2')\n" + + "result(false)\n" + "endTest()\n" + "startTest('Candidate B', 'Instantiator1')\n" + + "result(false)\n" + "endTest()\n" + "startTest('Candidate B', 'Instantiator2')\n" + + "result(false)\n" + "endTest()\n" + "startTest('Candidate C', 'Instantiator1')\n" + + "result(false)\n" + "endTest()\n" + "startTest('Candidate C', 'Instantiator2')\n" + + "result(false)\n" + "endTest()\n" + "endTests()\n", reporter.toString()); + } + + public void testReportsSuccessIfCandidateCanBeInstantiated() { + // Given... a TCK with some candidate classes: A, B and C. + TCK tck = new TCK(); + + tck.registerCandidate(CandidateA.class, "Candidate A"); + tck.registerCandidate(CandidateB.class, "Candidate B"); + + // And... a single ObjectInsantiator registered that can instantiate + // A but not B. + tck.registerObjenesisInstance(new SelectiveInstantiator(), "instantiator"); + + // When... the TCK tests are run + Reporter reporter = new RecordingReporter(); + tck.runTests(reporter); + + // Expect... the reporter to be notified that A succeeded + // but B failed. + assertEquals("" + "startTests()\n" + "startTest('Candidate A', 'instantiator')\n" + // A + "result(true)\n" + // true + "endTest()\n" + "startTest('Candidate B', 'instantiator')\n" + // B + "result(false)\n" + // false + "endTest()\n" + "endTests()\n", reporter.toString()); + } + + // Some sample classes used for testing. + + public static class SelectiveInstantiator implements Objenesis { + public Object newInstance(Class clazz) { + return clazz == CandidateA.class ? new CandidateA() : null; + } + + public ObjectInstantiator getInstantiatorOf(Class clazz) { + return null; + } + } + + public static class CandidateA { + } + + public static class CandidateB { + } + + public static class CandidateC { + } + + /** + * A poor man's mock. Using a recording test double to verify interactions between the TCK and + * the Recorder.

Note: This test case could be simplified by using a mock object library. + * However, I wanted to simplify dependencies - particularly as in the future, the mock libraries + * may depend on objenesis - getting into an awkward cyclical dependency situation. -Joe. + */ + private static class RecordingReporter implements Reporter { + + private final StringBuffer log = new StringBuffer(); + + public void startTests(String platformDescription, Collection allCandidates, + Collection allInstantiators) { + log.append("startTests()\n"); + } + + public void startTest(String candidateDescription, String objenesisDescription) { + log.append("startTest('").append(candidateDescription).append("', '").append( + objenesisDescription).append("')\n"); + } + + public void result(boolean instantiatedObject) { + log.append("result(").append(instantiatedObject).append(")\n"); + } + + public void exception(Exception exception) { + log.append("exception()\n"); + } + + public void endTest() { + log.append("endTest()\n"); + } + + public void endTests() { + log.append("endTests()\n"); + } + + public String toString() { + return log.toString(); + } + } +} diff -Nru objenesis-1.2/tck/test/org/objenesis/tck/TextReporterTest.java objenesis-1.2+full/tck/test/org/objenesis/tck/TextReporterTest.java --- objenesis-1.2/tck/test/org/objenesis/tck/TextReporterTest.java 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/tck/test/org/objenesis/tck/TextReporterTest.java 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1,87 @@ +/** + * Copyright 2006-2009 the original author or authors. + * + * 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. + */ +package org.objenesis.tck; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.Arrays; + +import junit.framework.TestCase; + +/** + * @author Joe Walnes + * @author Henri Tremblay + */ +public class TextReporterTest extends TestCase { + + private TextReporter textReporter; + private ByteArrayOutputStream summaryBuffer; + + protected void setUp() throws Exception { + super.setUp(); + summaryBuffer = new ByteArrayOutputStream(); + ByteArrayOutputStream logBuffer = new ByteArrayOutputStream(); + textReporter = new TextReporter(new PrintStream(summaryBuffer), new PrintStream(logBuffer)); + } + + public void testReportsSuccessesInTabularFormat() { + textReporter.startTests("Some platform", Arrays.asList(new String[] {"candidate A", + "candidate B", "candidate C"}), Arrays.asList(new String[] {"instantiator1", + "instantiator2", "instantiator3"})); + + textReporter.startTest("candidate A", "instantiator1"); + textReporter.result(false); + textReporter.startTest("candidate A", "instantiator2"); + textReporter.result(false); + textReporter.startTest("candidate A", "instantiator3"); + textReporter.result(true); + + textReporter.startTest("candidate B", "instantiator1"); + textReporter.result(true); + textReporter.startTest("candidate B", "instantiator2"); + textReporter.result(false); + textReporter.startTest("candidate B", "instantiator3"); + textReporter.result(true); + + textReporter.startTest("candidate C", "instantiator1"); + textReporter.exception(new RuntimeException("Problem")); + textReporter.startTest("candidate C", "instantiator2"); + textReporter.result(false); + textReporter.startTest("candidate C", "instantiator3"); + textReporter.result(true); + + textReporter.endTests(); + + textReporter.printResult(true); + + ByteArrayOutputStream expectedSummaryBuffer = new ByteArrayOutputStream(); + PrintStream out = new PrintStream(expectedSummaryBuffer); + out.println("Running TCK on platform: Some platform"); + out.println(); + out.println("Not serializable parent constructor called: Y"); + out.println(); + out.println(" instantiator1 instantiator2 instantiator3 "); + out.println("candidate A n n Y "); + out.println("candidate B Y n Y "); + out.println("candidate C n n Y "); + out.println(); + out.println("--- FAILED: 5 error(s) occured ---"); + out.println(); + + assertEquals(expectedSummaryBuffer.toString(), summaryBuffer.toString()); + } + +} diff -Nru objenesis-1.2/update_license.bat objenesis-1.2+full/update_license.bat --- objenesis-1.2/update_license.bat 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/update_license.bat 2009-06-17 23:38:21.000000000 +0000 @@ -0,0 +1 @@ +%M2_HOME%\bin\mvn.bat install -Plicense diff -Nru objenesis-1.2/website/pom.xml objenesis-1.2+full/website/pom.xml --- objenesis-1.2/website/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/pom.xml 2009-08-26 21:12:00.000000000 +0000 @@ -0,0 +1,115 @@ + + + + + + 4.0.0 + + org.objenesis + objenesis-parent + 1.2 + .. + + objenesis-website + Objenesis website + pom + + + apidocs + + + + + + org.objenesis + objenesis + ${project.version} + + + + + + + maven-resources-plugin + + + copy-resources + prepare-package + + copy-resources + + + ${project.build.directory}/site + \ + ISO-8859-1 + + + ${basedir}/site + true + + + + + + copy-javadoc + package + + copy-resources + + + ${project.build.directory}/xsite/apidocs + UTF-8 + + + ${basedir}/../main/target/apidocs + false + + + + + + + + org.codehaus.xsite + xsite-maven-plugin + 1.0 + + ${project.build.directory}/site + content/sitemap.xml + templates/skin.html + resources + ${project.build.directory}/xsite + + + + package + + run + + + + + + maven-deploy-plugin + + true + + + + + + diff -Nru objenesis-1.2/website/.project objenesis-1.2+full/website/.project --- objenesis-1.2/website/.project 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/.project 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,29 @@ + + + objenesis-website + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.common.project.facet.core.builder + + + + + org.eclipse.wst.validation.validationbuilder + + + + + + org.eclipse.wst.common.project.facet.core.nature + org.eclipse.wst.common.modulecore.ModuleCoreNature + org.eclipse.wst.jsdt.core.jsNature + + diff -Nru objenesis-1.2/website/.settings/org.eclipse.core.resources.prefs objenesis-1.2+full/website/.settings/org.eclipse.core.resources.prefs --- objenesis-1.2/website/.settings/org.eclipse.core.resources.prefs 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/.settings/org.eclipse.core.resources.prefs 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,14 @@ +#Mon Jun 22 00:42:45 CEST 2009 +eclipse.preferences.version=1 +encoding//site/content/acknowledgements.html=ISO-8859-1 +encoding//site/content/details.html=ISO-8859-1 +encoding//site/content/download.html=ISO-8859-1 +encoding//site/content/embedding.html=ISO-8859-1 +encoding//site/content/index.html=ISO-8859-1 +encoding//site/content/license.html=ISO-8859-1 +encoding//site/content/notes.html=ISO-8859-1 +encoding//site/content/sitemap.xml=ISO-8859-1 +encoding//site/content/source.html=ISO-8859-1 +encoding//site/content/support.html=ISO-8859-1 +encoding//site/content/tutorial.html=ISO-8859-1 +encoding/site=ISO-8859-1 diff -Nru objenesis-1.2/website/site/content/acknowledgements.html objenesis-1.2+full/website/site/content/acknowledgements.html --- objenesis-1.2/website/site/content/acknowledgements.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/acknowledgements.html 2007-01-11 01:24:00.000000000 +0000 @@ -0,0 +1,47 @@ + + + Acknowledgements + + + +

Objenesis was not written from scratch. It was the result of spotting duplication amongst + other open source projects that were doing similar things and creating a best-of-breed solution.

+ +

Code from Objenesis was adapted from code from these projects:

+ + + +

Development Team

+ +
    +
  • Joe Walnes
  • +
  • Henri Tremblay
  • +
  • Leonardo Mesquita
  • +
+ +

To contact the developers, please use the discussion group.

+ +

Contributors

+ + + +

Supporting Services

+ + + + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/details.html objenesis-1.2+full/website/site/content/details.html --- objenesis-1.2/website/site/content/details.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/details.html 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,125 @@ + + + The Details + + + +

The Tutorial allows you to perfectly use Objenesis. +However, if you want implementation details, tools and more power, you're at +the right place.

+ +

Test your environment

+ +

Depending on you JVM and security manager, Objenesis might not be able to +instantiate some of your classes. If that's the case, first, we are highly +interested in knowing this limitation.

+ +

Then, to prevent this, we provide a TCK to run in your environment. You can +find it in our download page. It will print a report +to the standard output. Exceptions, if they occur, will be printed out to +the standard error. Tests are run ObjenesisStd +and ObjenesisSerializer +and are made of every kind of class types you might want to instantiate. So you can check if all +of them or at least the kind you want are correctly instantiated.

+ +

To launch from the command line, just type

+ +
java -jar objenesis-${project.version}-tck.jar
+ +

Note that objenesis jar is bundled in the TCK so no special classpath is needed.

+ +

To launch from within an application server, the easiest is to bundle it in your application +and to call org.objenesis.tck.Main.main() from your code.

+ +

Exception Handling

+ +

If something wrong occurs using Objenesis, you will normally get an +ObjenesisException +wrapping (for JVM 1.4 and more) the real exception. It is a RuntimeException so you don't have to +catch it. Some reasons why it fails:

+ +
    +
  • Using ObjenesisSerializer with a class that isn't Serializable.
  • +
  • Using ObjenesisSerializer, the constructor of the first parent class that isn't + Serializable throws an exception.
  • +
  • Your SecurityManager prevents Objenesis from working normally.
  • +
  • Objenesis isn't able to work for some reason. Please tell us
  • +
+ +

ObjectInstantiator caching

+ +

ObjenesisBase provides a built-in cache +that is activated by default. This cache keeps +ObjectInstantiator instances per Class. This improves performance quite a lot when the same Class +is frequently instantiated. For this reason, it is recommended to reuse Objenesis instances whenever +posssibly or to keep is as a singleton in your favorite dependency injection framework.

+ +

However, you can always disable the cache if needed.

+
+    Objenesis o = new ObjenesisStd(false); // cache disabled
+
+ +

The cache should behave correctly in an application server and not cause any memory leaks.

+ +

Use you own strategy

+ +

As you've seen in the Tutorial, Objenesis implementations +are determining the best instantiator using a strategy. It might occurs that you need +to implement your own strategy. Two possible reasons I can think of are that

+ +
    +
  • You want to specialize in a given JVM. Default strategies are + supporting all JVMs. This has a little performance cost so you might want to + provide a strategy that is optimized for your JVM. +
    +public class Sun14Strategy implements InstantiatorStrategy {
    +    public ObjectInstantiator newInstantiatorOf(Class type) {
    +        // return sun dedicated instantiator
    +        return new SunReflectionFactoryInstantiator(type);
    +    }
    +}
    +
  • +
  • Objenesis doesn't support your environment by default. In that + case, we would be really happy to add this support in our next version and + meanwhile, you can use your own strategy and instantiator to fix this.
  • +
+ +

From there, you can use this new strategy.

+
+// Directly
+Objenesis o = new ObjenesisBase(new Sun14Strategy());
+
+// Or inside your Objenesis own implementation
+public class ObjenesisSun14 extends ObjenesisBase {
+    public ObjenesisSun14() {
+       super(new Sun14Strategy());
+    }
+}
+
+ +

The Evil ObjenesisHelper

+ +

Static methods are considered a really bad practice. They can't be mocked or +replace easily. Worst, if the class keep a static state, you will fell in +class loading issues, memory leaks, module dependencies and so on. We +strongly recommend you not to use them.

+ +

However, if for some reason that we prefer ignore, you still want to use Objenesis +in a static way, you can do so. It's called ObjenesisHelper.

+ +

We prefer to provide it knowing that some of you will code it anyway. It a wrapper +over an ObjenesisStd +and ObjenesisSerializer +instance which are kept statically.

+ +

It can't be more straightforward to use:

+ +
+   Object o1 = ObjenesisHelper.newInstance(MyClass.class);
+   Object o2 = ObjenesisHelper.newSerializableInstance(MyClass.class);
+   ObjectInstantiator o3 = ObjenesisHelper.getInstantiatorOf(MyClass.class);
+   ObjectInstantiator o4 = ObjenesisHelper.getSerializableObjectInstantiatorOf(MyClass.class);
+
+ + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/download.html objenesis-1.2+full/website/site/content/download.html --- objenesis-1.2/website/site/content/download.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/download.html 2009-08-26 22:26:13.000000000 +0000 @@ -0,0 +1,22 @@ + + + Download + + + +

Current version is ${project.version}

+ + + +

Older versions can be found here

+ + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/embedding.html objenesis-1.2+full/website/site/content/embedding.html --- objenesis-1.2/website/site/content/embedding.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/embedding.html 2009-06-21 23:32:22.000000000 +0000 @@ -0,0 +1,66 @@ + + + Embedding + + + +Objenesis is jarjar and +maven-shade-plugin compliant. + +

Ant

+ +

A jarjar ant task is available. You just need to replace your usual jar task with +jarjar. Depending on the complexity of your project, you will then have different +parameters. Here's an example:

+ +
+	<jarjar jarfile="${temp directory}/easymockclassextension.jar">
+	  <fileset dir="tmp" includes="org/easymock/classextension/*.class
+	    org/easymock/classextension/internal/*.class"/>
+	  <zipfileset src="lib/objenesis-${project.version}.jar"/>
+	  <rule pattern="org.objenesis.**"
+	    result="org.easymock.classextension.internal.objenesis.@1"/>
+	</jarjar>
+
+ +

Maven

+ +

For jarjar, multiple unofficial plugins exist (here, +here and +here). However, you can use +the antrun plugin to call +the jarjar ant task.

+ +

Or you can use the maven-shade-plugin. +Here's an example:

+ +
+      <plugin>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
+          <artifactSet>
+            <includes>
+              <include>org.objenesis:objenesis</include>
+            </includes>
+          </artifactSet>
+          <relocations>
+            <relocation>
+              <pattern>org.objenesis</pattern>
+              <shadedPattern>org.easymock.classextension.internal.objenesis</shadedPattern>
+            </relocation>
+          </relocations>
+        </configuration>
+      </plugin>
+
+ + + diff -Nru objenesis-1.2/website/site/content/index.html objenesis-1.2+full/website/site/content/index.html --- objenesis-1.2/website/site/content/index.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/index.html 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,74 @@ + + + About + + + + +

Objenesis is a small Java library that serves one purpose:

+ +
    +
  • To instantiate a new object of a particular class.
  • +
+ +

When would you want this?

+ +

Java already supports this dynamic instantiation of classes using Class.newInstance(). + However, this only works if the class has an appropriate constructor. There are many times when a class + cannot be instantiated this way, such as when the class contains:

+ +
    +
  • Constructors that require arguments.
  • +
  • Constructors that have side effects.
  • +
  • Constructors that throw exceptions.
  • +
+ +

As a result, it is common to see restrictions in libraries stating that classes must require a + default constructor. Objenesis aims to overcomes these restrictions by bypassing the constructor on object + instantiation.

+ +

Typical uses

+ +

Needing to instantiate an object without calling the constructor is a fairly specialized task, however + there are certain cases when this is useful:

+
    +
  • Serialization, Remoting and Persistence + - Objects need to be instantiated and restored to a specific state, without invoking code. +
  • +
  • Proxies, AOP Libraries and Mock Objects + - Classes can be subclassed without needing to worry about the super() constructor. +
  • +
  • Container Frameworks + - Objects can be dynamically instantatiated in non-standard ways. +
  • +
+ +

Getting Started

+ +
    +
  1. Download objenesis-${project.version}.jar.
  2. +
  3. Read the twenty second tutorial.
  4. +
+ +

How it Works

+ +

Objenesis uses a variety of approaches to attempt to instantiate the object, depending on the type of object, +JVM version, JVM vendor and SecurityManager present. These are described in full in the + detailed documentation.

+ +

Avoiding the Dependency

+ +

For something as straight forward as instantiating an object, it can be a pain introducing yet another + library dependency into your project. Objenesis is easy to embed in your + existing library so your end users don't even know it's there.

+ + +

Supported JVMs

+ +

The list of tested JVMs is available here. +Other JVMs might be supported be haven't been tested yet. You can test your environment using the +TCK and we would be glad to have feedback +on any supported / unsupported JVM.

+ + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/license.html objenesis-1.2+full/website/site/content/license.html --- objenesis-1.2/website/site/content/license.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/license.html 2009-06-21 21:55:44.000000000 +0000 @@ -0,0 +1,37 @@ + + + License + + + +

Objenesis is open source, under the Apache 2.0 license.

+ +

If, for any reason, this license is not appropriate for you, please + contact the development team so we can discuss + alternatives.

+ +

Previous license

+ +

Versions of Objenesis before version 1.2 are under the MIT license defined below.

+ +
Copyright (c) 2003-2009, Objenesis Team and all contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/notes.html objenesis-1.2+full/website/site/content/notes.html --- objenesis-1.2/website/site/content/notes.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/notes.html 2009-08-23 23:36:56.000000000 +0000 @@ -0,0 +1,27 @@ + + + Release notes + + + +

Version 1.2

+ +
    +
  • Now under Apache 2.0 license
  • +
  • objenesis.jar is an OSGi bundle
  • +
+ +

Version 1.1

+ +
    +
  • Standard support of Aonix PERC (no Serialization support)
  • +
+ +

Version 1.0

+ +
    +
  • Initial version, support for Sun Hotspot, GCJ and BEA JRockit JVMs
  • +
+ + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/sitemap.xml objenesis-1.2+full/website/site/content/sitemap.xml --- objenesis-1.2/website/site/content/sitemap.xml 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/sitemap.xml 2007-12-09 21:00:18.000000000 +0000 @@ -0,0 +1,21 @@ + +
+ Objenesis + index.html + license.html + download.html +
+
+ Documentation + tutorial.html + details.html + embedding.html +
+
+ Project Details + support.html + acknowledgements.html + source.html + notes.html +
+
\ No newline at end of file diff -Nru objenesis-1.2/website/site/content/source.html objenesis-1.2+full/website/site/content/source.html --- objenesis-1.2/website/site/content/source.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/source.html 2006-11-11 17:05:05.000000000 +0000 @@ -0,0 +1,13 @@ + + + Source Repository + + + +

The source repository for Objenesis is hosted by Google Code Project Hosting.

+ + + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/support.html objenesis-1.2+full/website/site/content/support.html --- objenesis-1.2/website/site/content/support.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/support.html 2006-11-11 17:05:05.000000000 +0000 @@ -0,0 +1,17 @@ + + + Getting Support + + + + + + + \ No newline at end of file diff -Nru objenesis-1.2/website/site/content/tutorial.html objenesis-1.2+full/website/site/content/tutorial.html --- objenesis-1.2/website/site/content/tutorial.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/content/tutorial.html 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,86 @@ + + + Twenty Second Tutorial + + + +

There are two main interfaces in Objenesis:

+ +
    +
  • ObjectInstantiator + - Instantiates multiple instances of a single class. +
    interface ObjectInstantiator {
    +  Object newInstance();
    +}
    +
  • +
  • InstantiatorStrategy + - A particular strategy for how to instantiate a class (as this differs for different types of classes). +
    interface InstantiatorStrategy {
    +  ObjectInstantiator newInstantiatorOf(Class type);
    +}
    +
  • +
+ +

Note: All Objenesis classes are in the + org.objenesis package.

+ +

Step By Step

+ +

There are many different strategies that Objenesis uses for instantiating objects based on the JVM vendor, +JVM version, SecurityManager and type of class being instantiated.

+ +

We have defined that two different kinds of instantiation are required:

+ +
    +
  • Stardard - No constructor will be called
  • +
  • Serializable compliant - Acts like an object instantiated by java standard + serialization. It means that the constructor of the first non-serializable parent class will + be called. However, readResolve is not called and we never check if the object is serializable.
  • +
+ +

The simplest way to use Objenesis is by using ObjenesisStd (Standard) and +ObjenesisSerializer (Serializable compliant). By default, +automatically determines the best strategy - so you don't have to.

+ +
Objenesis objenesis = new ObjenesisStd(); // or ObjenesisSerializer
+ +

Once you have the Objenesis implementation, you can then create an ObjectInstantiator, for a specific type.

+ +
ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(MyThingy.class);
+ +

Finally, you can use this to instantiate new instances of this type.

+ +
MyThingy thingy1 = (MyThingy)thingyInstantiator.newInstance();
+MyThingy thingy2 = (MyThingy)thingyInstantiator.newInstance();
+MyThingy thingy3 = (MyThingy)thingyInstantiator.newInstance();
+ +

Performance and Threading

+ +

To improve performance, it is best to reuse the ObjectInstantiator + objects as much as possible. For example, if you are instantiating multiple instances of a specific class, + do it from the same ObjectInstantiator. +

+ +

Both InstantiatorStrategy and ObjectInstantiator can be shared between multiple + threads and used concurrently. They are thread safe.

+ +

That Code Again

+ +

(For the impatient)

+ +
+Objenesis objenesis = new ObjenesisStd(); // or ObjenesisSerializer
+MyThingy thingy1 = (MyThingy) objenesis.newInstance(MyThingy.class);
+
+// or (a little bit more efficient if you need to create many objects)
+
+Objenesis objenesis = new ObjenesisStd(); // or ObjenesisSerializer
+ObjectInstantiator thingyInstantiator = objenesis.getInstantiatorOf(MyThingy.class);
+
+MyThingy thingy2 = (MyThingy)thingyInstantiator.newInstance();
+MyThingy thingy3 = (MyThingy)thingyInstantiator.newInstance();
+MyThingy thingy4 = (MyThingy)thingyInstantiator.newInstance();
+
+ + + Binary files /tmp/df2WpOTxdn/objenesis-1.2/website/site/resources/objenesis.png and /tmp/6KNsnI1NV4/objenesis-1.2+full/website/site/resources/objenesis.png differ diff -Nru objenesis-1.2/website/site/resources/style.css objenesis-1.2+full/website/site/resources/style.css --- objenesis-1.2/website/site/resources/style.css 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/resources/style.css 2006-11-11 17:05:05.000000000 +0000 @@ -0,0 +1,344 @@ +/*--------------------------------------------------------------------------- + * Two- and three-column layout + */ + +#banner { + top: 0px; + left: 0px; + right: 0px; + height: 90px; +} + +#left { + position: absolute; + z-index: 2; + left: 8px; + width: 184px; + top: 100px; + bottom: 8px; + margin: 0px; + padding: 0px; +} + +#right { + position: absolute; + z-index: 1; + right: 8px; + width: 184px; + top: 100px; + bottom: 8px; + margin: 0px; + padding: 0px; +} + +.Content3Column { + position: absolute; + top: 100px; + bottom: 8px; + left: 208px; + right: 216px; +} + +.Content2Column { + position: absolute; + top: 100px; + bottom: 8px; + left: 208px; + right: 16px; +} + +#center { + z-index: 3; + margin: 0px; + border: none; + padding-bottom: 8px; +} + + +/*--------------------------------------------------------------------------- + * Default element styles + */ + +body { + padding: 0px; + margin: 0px; + border: 0px; + + font-family: helvetica, arial, sans-serif; + font-size: 12px; + + background-color: white; + color: black; +} + +h1, h2, h3, h4, h5, h6 { + margin: 0px; + border: 0px; + padding: 0px; + font-weight: normal; +} + +a:link { color: #6e61ad; } +a:active { color: red; } +a:hover { color: red; } +a:visited { color: black; } + +iframe { + width:100%; + height: 800px; + border: 0px; +} + +img { + border: 0px; + padding: 0px; + margin: 0px; +} + +p { + border: 0px; + padding: 0px; + margin: 0px; + margin-bottom: 10px; +} + +blockquote { + margin-bottom: 10px; +} + +td { + font-size: 12px; + padding: 2px; +} + +th { + font-size: 12px; + font-weight: bold; + white-space: nowrap; + padding: 2px; +} + +th.Row { + text-align: left; + vertical-align: top; +} + +ul, ol { + border: 0px; + padding: 0px; + margin-top: 0px; + margin-bottom: 12px; + margin-left: 20px; +} + + +/*--------------------------------------------------------------------------- + * Page banner + */ + +#banner { + margin: 0px; + border: 0px; + border-bottom: 1px solid #c8f; + padding: 0px; + background-color: #e0d0f0; + color: #606; + vertical-align: bottom; +} + +#banner a { text-decoration: none; } +#banner a:visited { color: #6e61ad; } +#banner a:hover { color: red; } +#banner a:active { color: red; } + +#logo { + position: absolute; + top: 5px; + left: 8px; +} + +#versions { + position: absolute; + width: auto; + right: 0px; + top: 0px; + margin: 8px; + font-weight: normal; +} + +/*--------------------------------------------------------------------------- + * Page content + */ + +#content { + margin: 0px; + background-color: white; + color: black; + height: 100%; +} + +#content h1 { + width: 100%; + font-size: 18px; + background-color: #6e61ad; + color: white; + padding: 2px; + padding-left: 6px; + margin-top: 24px; + margin-bottom: 12px; +} + +#content .FirstChild { /* IE doesn't understand first-child pseudoelement */ + margin-top: 0px; +} + +#content a { text-decoration: underline; } +#content a:link { color: #6e61ad; } +#content a:visited { color: #6e61ad; } +#content a:active { color: red; } +#content a:hover { color: red; } + +#content h2 { + margin-top: 24px; + border-top: 1px solid #060; + margin-bottom: 16px; + font-size: 15px; + font-weight: bold; + background-color: #6e61ad; + padding: 2px; +} + +#content li { + margin-bottom: 6px; +} + +#content th { + background-color: #afa; +} + +#content td { + background-color: #dfd; +} + +pre { + padding: 4px; + font-family: courier new, monospace; + font-size: 11px; + border: 1px solid #6e61ad; + background-color: #e0d0f0; + color: black; +} + +.highlight { + background-color: #6e61ad; + border: 1px dotted #060; + padding: 5px; +} + + + +/*--------------------------------------------------------------------------- + * Side panels + */ + +.SidePanel { + background-color: white; + padding: 0px; + font-size: 11px; +} + +.SidePanel h1 { + margin: 0px; + border: 0px; + padding: 4px; + + color: #6e61ad; + + font-size: 12px; + font-weight: bold; +} + + +.SidePanel a { text-decoration: none; } +.SidePanel a:link { color: #6e61ad; } +.SidePanel a:visited { color: #6e61ad; } +.SidePanel a:active { color: red; } +.SidePanel a:hover { color: red; } + +/*--------------------------------------------------------------------------- + * Menus + */ + +.MenuGroup { + border-left: 1px solid #6e61ad; + border-top: 1px solid #6e61ad; + border-bottom: 1px solid white; /* IE work-around */ + + margin-bottom: 8px; + background-color: white; + color: #060; +} + +.MenuGroup ul { + margin: 0px; + padding-left: 4px; + list-style-type: none; +} + +.MenuGroup li { + padding: 2px; +} + +.MenuGroup .currentLink { +/* background-color: #060;*/ + background-color: #e0d0f0; + color: #000; +} + + +/*--------------------------------------------------------------------------- + * News panel + */ + +.NewsGroup { + border-left: 1px solid #afa; + border-top: 1px solid #afa; + border-bottom: 1px solid white; /* IE workaround */ + margin-bottom: 8px; + + color: #060; +} + +.NewsItem { + margin: 4px; +} + +.NewsDate { + font-weight: bold; + margin: 0px; + padding: 0px; +} + +.NewsText { + padding: 0px; + margin: 0px; + margin-bottom: 8px; +} + +.NewsText a { text-decoration: underline; } +.NewsText a:link { color: #060; } +.NewsText a:visited { color: #060; } +.NewsText a:active { color: red; } +.NewsText a:hover { color: red; } + +.NewsMore { + font-size: smaller; + margin: 4px; + margin-top: 8px; + text-align: left; +} + +.NewsGroup td { + font-size: 12px; +} + diff -Nru objenesis-1.2/website/site/templates/skin.html objenesis-1.2+full/website/site/templates/skin.html --- objenesis-1.2/website/site/templates/skin.html 1970-01-01 00:00:00.000000000 +0000 +++ objenesis-1.2+full/website/site/templates/skin.html 2009-06-21 23:05:58.000000000 +0000 @@ -0,0 +1,41 @@ + + + + Objenesis : \${title} + + + \${head} + + + + + +
+
+

\${title}

+ \${body} +

+
+
+ +
+ <#list sitemap.sections as section> + + +
+ + +