pax_global_header00006660000000000000000000000064133622244040014512gustar00rootroot0000000000000052 comment=e2da695362c07e873d57a609ee87fd9cbce55865 objenesis-3.0.1/000077500000000000000000000000001336222440400134745ustar00rootroot00000000000000objenesis-3.0.1/.editorconfig000066400000000000000000000007521336222440400161550ustar00rootroot00000000000000# EditorConfig helps developers define and maintain consistent # coding styles between different editors and IDEs # editorconfig.org root = true [*] # Change these settings to your own preference indent_style = space indent_size = 3 # We recommend you to keep these unchanged end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false [*.html] indent_size = 2 [*.jsp] indent_size = 2 [*.xml] indent_size = 2 objenesis-3.0.1/.gitignore000066400000000000000000000003661336222440400154710ustar00rootroot00000000000000target/ eclipse_config/ .classpath .project org.eclipse.m2e.core.prefs org.eclipse.core.resources.prefs org.eclipse.pde.core.prefs *.iml .idea/ sys$command # maven-release-plugin release.properties pom.xml.next pom.xml.releaseBackup pom.xml.tag objenesis-3.0.1/.idea/000077500000000000000000000000001336222440400144545ustar00rootroot00000000000000objenesis-3.0.1/.idea/copyright/000077500000000000000000000000001336222440400164645ustar00rootroot00000000000000objenesis-3.0.1/.idea/copyright/Objenesis.xml000066400000000000000000000014651336222440400211350ustar00rootroot00000000000000 objenesis-3.0.1/.idea/copyright/profiles_settings.xml000066400000000000000000000001231336222440400227450ustar00rootroot00000000000000 objenesis-3.0.1/.travis.yml000066400000000000000000000000721336222440400156040ustar00rootroot00000000000000language: java sudo: false branches: only: - master objenesis-3.0.1/Benchmarks.md000066400000000000000000000050601336222440400160740ustar00rootroot00000000000000Here are multiple benchmarks that are meant to verify Objenesis performance. The source code is available [here](https://github.com/easymock/objenesis/tree/master/benchmark) if you want to challenge it. # Sun implementations (CreateObject) This benchmark compares two implementations working on HotSpot. They are instantiating the class Object. We have also added an instantiation with the default constructor. The munged constructor version is a special constructor HotSpot is using to perform serialization. The unsafe version is using `Unsafe.allocateInstance`. A bit easier to implement in Objenesis but much slower than the munged version. So we kept the later one as the default for HotSpot. Benchmark |Mean |Mean error|Units ---------------------------|---------|----------|------- createObjectWithConstructor|3.509.724|0.017 |nsec/op createObjectWithSun |6.995 |0.087 |nsec/op createObjectWithUnsafe |20.382 |0.379 |nsec/op # Instantiator creation (ConcurrentGetInstantiator) When the client code ask for the instantiator of a given class, Objenesis creates one and can cache it or not. If it is cached, the next time the instantiator is requested for the same class, the cached instantiator will be returned instead of a new one. Instantiators are thread-safe so there's no need to worry. During migration to Java 5, the cache implementation using a synchronize was replaced by a concurrent collection. This benchmark shows the difference in performance between the two cache implementations and of Objenesis without cache. Type |Mean |Units -----------------|-----------|------- Cached (Java 1.3)|2535.952 |nsec/op Cached (Java 5) |238.946 |nsec/op No cache (Java 5)|5253937.944|nsec/op Then, the standard strategy used by Objenesis deduces the best instantiator for your platform. Another possibility is to decide that you known the platform you are on and you prefer to use the single instantiator that will create always the same type of instantiator using reflection. Finally, if you want to avoid using reflection, you can use a custom strategy returning always one instantiator using "new". As you will see, it doesn't really matter which one you use, the performance is similar. Type |Mean |Units --------|-----------|------- Custom |5270008.460|nsec/op Single |5205981.442|nsec/op Standard|5269205.477|nsec/op Both benchmarks are performed in a highly concurrent environment to reflect what is expected to be normal usage. They were executed on Windows 8 using Java 1.7.0_25 64 bits version.objenesis-3.0.1/CONTRIBUTING.md000066400000000000000000000007701336222440400157310ustar00rootroot00000000000000# Project License: Apache License Version 2.0 By contributing code you automatically agree with the following points regarding licensing: * You will only Submit Contributions where You have authored 100% of the content. * You will only Submit Contributions to which You have the necessary rights. This means that if You are employed You have received the necessary permissions from Your employer to make the Contributions. * Whatever content You Contribute will be provided under the Project License. objenesis-3.0.1/LICENSE.txt000066400000000000000000000261361336222440400153270ustar00rootroot00000000000000 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. objenesis-3.0.1/README.md000066400000000000000000000101051336222440400147500ustar00rootroot00000000000000# Objenesis Objenesis is a library dedicated to bypass the constructor when creating an object. On any JVM there is. You can find the website and user documentation at [objenesis.org](http://objenesis.org). # Developer information ## Project status [![Build Status](https://travis-ci.org/easymock/objenesis.svg?branch=master)](https://travis-ci.org/easymock/objenesis) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.objenesis/objenesis/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.objenesis/objenesis) ## Environment setup I'm using: - Maven 3.5.3 - IntelliJ Ultimate 2018.2 (thanks to JetBrains for the license) (it should also work with Eclipse) To configure your local workspace: - Import the Maven parent project to Eclipse or IntelliJ - Import the Eclipse formatting file `objenesis-formatting.xml` (usable in Eclipse or IntelliJ) ## To build with Maven There are two different levels of build. ### Build without any active profile It is a basic compilation of the application. `mvn install` ### Full build This build will create the source and javadoc jars and run spotbugs. `mvn install -Pfull` ## To run special builds ### Run the Android TCK - Install the Android SDK (`brew cask install android-sdk`) - Install `platform-tools` and `build-tools` using the sdkmanager (`sdkmanager "platform-tools" "build-tools"`) - Add an `ANDROID_HOME` to target the Android SDK (`export ANDROID_HOME=$(realpath $(echo "$(dirname $(readlink $(which sdkmanager)))/../.."))`) - Configure a device (real or simulated) and launch it - Activate the debug mode if it's a real device - `mvn package -Pandroid` ### Run the benchmarks ```bash mvn package -Pbenchmark cd benchmark ./launch.sh ``` ### Generate the website `mvn package -Pwebsite` ## To update the versions - `mvn versions:set -DnewVersion=X.Y -Pall` - `mvn versions:commit -Pall` if everything is ok, `mvn versions:revert -Pall` otherwise ## Configure to deploy to the Sonatype maven repository - You will first need to add something like this to your settings.xml ```xml sonatype-nexus-snapshots sonatypeuser sonatypepassword sonatype-nexus-staging sonatypeuser sonatypepassword ``` - Then follow the instructions from the site below to create your key to sign the deployed items http://www.sonatype.com/people/2010/01/how-to-generate-pgp-signatures-with-maven/ ## To check dependencies and plugins versions `mvn versions:display-dependency-updates versions:display-plugin-updates -Pall` ## To update the license `mvn validate license:format -Pall` ## To release * Add the release notes in `website/site/content/notes.html` You use this code to generate it ```bash # Get the milestone matching the version milestone=$(curl -s "https://api.github.com/repos/easymock/objenesis/milestones" | jq ".[] | select(.title==\"$version\") | .number") echo "

Version $version ($(date '+%Y-%m-%d'))

" echo echo "" ``` * Add these servers to your `settings.xml` ```xml bintray your-user-name your-api-key gpg.passphrase your-passphrase ``` * Set `gpg_passphrase`, `bintray_api_key` and `bintray_user` environment variables * Launch an Android device (virtual or physical) * Launch `./deploy.sh version` * Answer the questions (normally, just acknowledge the proposed default) * Follow the instructions If something fails and you need to rollback a bit, the following commands might help: ```bash mvn release:rollback -Pall git tag -d $version git push origin :refs/tags/$version git reset --hard HEAD~2 ``` ## Deploy the website * Make sure the pom is at the version you want to release * Launch `./deploy-website.sh` objenesis-3.0.1/SupportedJVMs.md000066400000000000000000000063521336222440400165510ustar00rootroot00000000000000# List of currently supported JVMs * Sun Hotspot VM, versions 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 9, 10, 11 * OpenJDK 6, 7, 8, 9, 10, 11 * Android API level 8 to 26 (Serialization support starting from Honeycomb) * Azul Zulu (tested on 1.8.0_45-b14) * Azul Zing JDK 1.8 (tested on 1.8.0-zing_16.10.1.0-b2) * IKVM (tested on 8.1.5717) * BEA JRockit R27, R28 * GCJ version 3.4.4 (tested on Windows/Cygwin) * Aonix PERC (no serialization support), tested on version 5.0.0667 Support per Objenesis versions: * 1.x supports Java 1.3 to 1.7 * 2.x supports Java 1.5 to 10 * 3.x supports Java 1.8 to 11 ## Google App Engine GAE is only really partially supported due to the constraints of the platform. Only serializable objects can be instantiated. So the Serializing instantiator will behave almost correctly. There is only one loophole: `readResolve` will be called if implemented by the created class. This isn't the case on the other platforms. The Standard instantiator will * call the constructor from the first non-serializable parent if the class is serializable * the default constructor if the class is not This is far from ideal but will kinda work in some cases. Calling a constructor defeats a bit the purpose of Objenesis to say the least... If someone has a better solution, we are listening. This is the result of the TCK. Remember that 'Y' means the class was instantiated without exception. It doesn't mean that no constructor was called. |Class type |Objenesis serializer|Objenesis std| |---------------------------------------------------|:-----------------:|:-----------:| |Constructor throwing exception |N/A |n | |Constructor throwing exception (serializable) |Y |Y | |Constructor with arguments |N/A |n | |Constructor with arguments (serializable) |Y |Y | |Constructor with mandatory arguments |N/A |n | |Constructor with mandatory arguments (serializable)|Y |Y | |Default package constructor |N/A |Y | |Default package constructor (serializable) |Y |Y | |Default private constructor |N/A |Y | |Default private constructor (serializable) |Y |Y | |Default protected constructor |N/A |Y | |Default protected constructor (serializable) |Y |Y | |Default public constructor |N/A |Y | |Default public constructor (serializable) |Y |Y | |No constructor |N/A |Y | |No constructor (serializable) |Y |Y | |Serializable replacing with another class |Y |Y | |Serializable resolving to another class |n |n | |Serializable with ancestor throwing exception |N/A |n | objenesis-3.0.1/benchmark/000077500000000000000000000000001336222440400154265ustar00rootroot00000000000000objenesis-3.0.1/benchmark/.settings/000077500000000000000000000000001336222440400173445ustar00rootroot00000000000000objenesis-3.0.1/benchmark/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000575201336222440400243370ustar00rootroot00000000000000eclipse.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.7 org.eclipse.jdt.core.compiler.compliance=1.7 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.7 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_annotation=0 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_method_declaration=0 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_resources_in_try=80 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.alignment_for_union_type_in_multicatch=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_import_groups=1 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.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=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_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=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.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 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.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 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_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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_try=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_semicolon_in_try_resources=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_try=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_try=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_parenthesized_expression_in_throw=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_semicolon_in_try_resources=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.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true 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.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 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_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true objenesis-3.0.1/benchmark/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000057301336222440400240200ustar00rootroot00000000000000eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Objenesis formatter_settings_version=12 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= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=true sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true objenesis-3.0.1/benchmark/launch.bat000066400000000000000000000002771336222440400173760ustar00rootroot00000000000000mvn clean package echo "Possible filters" echo "org.objenesis.benchmark.CreateObject.*" echo "org.objenesis.benchmark.ConcurrentGetInstantiator.*" java -jar target/benchmarks.jar %* objenesis-3.0.1/benchmark/launch.sh000077500000000000000000000014571336222440400172460ustar00rootroot00000000000000#!/usr/bin/env bash # # Copyright 2006-2018 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. # mvn clean package echo "Possible filters:" echo " org.objenesis.benchmark.CreateObject.*" echo " org.objenesis.benchmark.ConcurrentGetInstantiator.*" java -jar target/benchmarks.jar $* objenesis-3.0.1/benchmark/pom.xml000066400000000000000000000101631336222440400167440ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 objenesis-benchmark Objenesis Benchmark Objenesis' Benchmark http://objenesis.org 1.8 1.21 benchmarks org.objenesis objenesis ${project.version} org.openjdk.jmh jmh-core ${jmh.version} org.openjdk.jmh jmh-generator-annprocess ${jmh.version} provided cglib cglib-nodep 3.2.8 maven-compiler-plugin ${javac.target} ${javac.target} ${javac.target} com.keyboardsamurais.maven maven-timestamp-plugin com.mycila license-maven-plugin maven-remote-resources-plugin maven-deploy-plugin true maven-shade-plugin package shade ${uberjar.name} org.openjdk.jmh.Main *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA objenesis-3.0.1/benchmark/src/000077500000000000000000000000001336222440400162155ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/000077500000000000000000000000001336222440400171415ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/java/000077500000000000000000000000001336222440400200625ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/java/org/000077500000000000000000000000001336222440400206515ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/java/org/objenesis/000077500000000000000000000000001336222440400226325ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/java/org/objenesis/benchmark/000077500000000000000000000000001336222440400245645ustar00rootroot00000000000000objenesis-3.0.1/benchmark/src/main/java/org/objenesis/benchmark/ConcurrentGetInstantiator.java000066400000000000000000000066041336222440400326170ustar00rootroot00000000000000/* * Copyright 2006-2018 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.benchmark; import net.sf.cglib.proxy.Enhancer; import net.sf.cglib.proxy.NoOp; import org.objenesis.Objenesis; import org.objenesis.ObjenesisStd; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator; import org.objenesis.strategy.BaseInstantiatorStrategy; import org.objenesis.strategy.InstantiatorStrategy; import org.objenesis.strategy.SingleInstantiatorStrategy; import org.objenesis.strategy.StdInstantiatorStrategy; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; /** * Benchmark comparing different instantiator strategies * * @author Henri Tremblay */ @BenchmarkMode(Mode.AverageTime) @Threads(32) @Fork(2) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 10, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Benchmark) public class ConcurrentGetInstantiator { private static final int COUNT = 1000; public static class SunInstantiatorStrategy extends BaseInstantiatorStrategy { @Override public ObjectInstantiator newInstantiatorOf(Class type) { return new SunReflectionFactoryInstantiator<>(type); } } InstantiatorStrategy std = new StdInstantiatorStrategy(); InstantiatorStrategy single = new SingleInstantiatorStrategy(SunReflectionFactoryInstantiator.class); InstantiatorStrategy custom = new SunInstantiatorStrategy(); Objenesis cachedStd = new ObjenesisStd(); Objenesis uncachedStd = new ObjenesisStd(false); Class[] toInstantiate = new Class[COUNT]; @State(Scope.Thread) public static class ThreadState { int index = 0; } @Setup public void setUp() { for(int i = 0; i < COUNT; i++) { Enhancer enhancer = new Enhancer(); enhancer.setUseCache(false); // deactivate the cache to get a new instance each time enhancer.setCallbackType(NoOp.class); Class c = enhancer.createClass(); toInstantiate[i] = c; } } @Benchmark public ObjectInstantiator std(ThreadState state) { return std.newInstantiatorOf(toInstantiate[state.index++ % COUNT]); } @Benchmark public ObjectInstantiator single(ThreadState state) { return single.newInstantiatorOf(toInstantiate[state.index++ % COUNT]); } @Benchmark public ObjectInstantiator custom(ThreadState state) { return custom.newInstantiatorOf(toInstantiate[state.index++ % COUNT]); } @Benchmark public ObjectInstantiator cachedStd(ThreadState state) { return cachedStd.getInstantiatorOf(toInstantiate[state.index++ % COUNT]); } @Benchmark public ObjectInstantiator uncachedStd(ThreadState state) { return uncachedStd.getInstantiatorOf(toInstantiate[state.index++ % COUNT]); } } objenesis-3.0.1/benchmark/src/main/java/org/objenesis/benchmark/CreateObject.java000066400000000000000000000073461336222440400277730ustar00rootroot00000000000000/* * Copyright 2006-2018 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.benchmark; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator; import org.objenesis.instantiator.sun.UnsafeFactoryInstantiator; import org.openjdk.jmh.annotations.*; import sun.misc.Unsafe; import sun.reflect.ReflectionFactory; import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.util.concurrent.TimeUnit; /** * Benchmark comparing different instantiators * * @author Henri Tremblay */ @BenchmarkMode(Mode.AverageTime) @Fork(2) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 10, time = 1) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Benchmark) public class CreateObject { ObjectInstantiator sunInstantiator; ObjectInstantiator unsafeInstantiator; Unsafe unsafe; Constructor constructor; Class type = Object.class; @SuppressWarnings("unchecked") private Constructor getConstructor() { try { ReflectionFactory factory = ReflectionFactory.getReflectionFactory(); Constructor objectConstructor =type.getConstructor((Class[]) null); Constructor c = (Constructor) factory.newConstructorForSerialization(type, objectConstructor); return c; } catch (Exception e) { throw new RuntimeException(e); } } private Unsafe getUnsafe() { Field f; try { f = Unsafe.class.getDeclaredField("theUnsafe"); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } f.setAccessible(true); try { return (Unsafe) f.get(null); } catch (IllegalAccessException e) { throw new RuntimeException(e); } } @Setup public void prepare() { sunInstantiator = new SunReflectionFactoryInstantiator<>(type); unsafeInstantiator = new UnsafeFactoryInstantiator<>(type); unsafe = getUnsafe(); constructor = getConstructor(); } @Benchmark public Object createObjectWithConstructor() { return new Object(); } @Benchmark public Object createObjectWithMungedConstructor() { return sunInstantiator.newInstance(); } @Benchmark public Object createObjectWithMungedConstructorRaw() throws Exception { return constructor.newInstance(); } @Benchmark public Object createObjectWithMungedConstructorRawAndCast() throws Exception { return type.cast(constructor.newInstance()); } @Benchmark public Object createObjectWithUnsafe() { return unsafeInstantiator.newInstance(); } @Benchmark public Object createObjectWithUnsafeRaw() throws Exception { return unsafe.allocateInstance(type); } @Benchmark public Object createObjectWithUnsafeRawAndCast() throws Exception{ return type.cast(unsafe.allocateInstance(type)); } @Benchmark public Object createObjectWithUnsafeRawException() { try { return unsafe.allocateInstance(type); } catch(InstantiationException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/deploy-website.sh000077500000000000000000000020341336222440400167660ustar00rootroot00000000000000#!/bin/bash function pause { echo read -p "Press [enter] to continue" } # to exit in case of error set -e # make sure the script is launched from the project root directory if [ "$(dirname $0)" != "." ]; then echo "The script should be launched from Objenesis root directory" exit 1 fi # clone the website branch echo "************** CLONE ************************" git clone --depth=1 --branch gh-pages git@github.com:easymock/objenesis.git site pushd site # delete all none hidden directories (keep .git for instance) ls -1 | xargs rm -rf # compile de new website pushd ../website mvn clean package popd # copy the new site to the branch cp -R ../website/target/xsite/* . # to help debugging in case of issue echo "************** STATUS************************" git status # push the site echo "************** COMMIT ***********************" git add --ignore-removal . git commit -m "from master $(git log | head -n 1)" pause echo "************** PUSH ************************" git push origin gh-pages popd rm -rf site objenesis-3.0.1/deploy.sh000077500000000000000000000056721336222440400153410ustar00rootroot00000000000000#!/bin/bash # This script expects: # - the version to be deployed as the first parameter # - bintray_user to be an environment variable # - bintray_api_key to be an environment variable # to exit in case of error set -e set -v function pause { echo read -p "Press [enter] to continue" } # make sure the version is passed in parameter if [ "$1" == "" ]; then echo "Version to deploy should be provided" exit 1 fi version=$1 if [ "$(git branch | grep ${version})" == "${version}" ]; then echo "A branch named $version clashes with the version tag" exit 1 fi message="should be an environment variable" [ -z "$gpg_passphrase" ] && echo "gpg_passphrase $message" && exit 1 [ -z "$bintray_api_key" ] && echo "bintray_api_key $message" && exit 1 [ -z "$bintray_user" ] && echo "bintray_user $message" && exit 1 # Weird fix required by GPG. See https://github.com/keybase/keybase-issues/issues/1712. You will have to enter the passphrase on screen export GPG_TTY=$(tty) mvn release:prepare -Pall,full,release # Need to push now because release:perform will checkout the remote tag git push git push --tags mvn release:perform -Pall,full,release echo "Please add the release notes in github" open "https://github.com/easymock/objenesis/tags" pause # Create the distribution in bintray date=$(date "+%Y-%m-%d") content="{ \"name\": \"$version\", \"desc\": \"$version\", \"released\": \"${date}T00:00:00.000Z\", \"github_use_tag_release_notes\": true, \"vcs_tag\": \"$version\" }" curl -XPOST -H "Content-Type: application/json" -u${bintray_user}:${bintray_api_key} \ -d "$content" https://api.bintray.com/packages/easymock/distributions/objenesis/versions curl -v -H "X-GPG-PASSPHRASE: $gpg_passphrase" -u${bintray_user}:${bintray_api_key} -T "main/target/objenesis-${version}-bin.zip" https://api.bintray.com/content/easymock/distributions/objenesis/${version}/objenesis-${version}-bin.zip?publish=1 curl -v -H "X-GPG-PASSPHRASE: $gpg_passphrase" -u${bintray_user}:${bintray_api_key} -T "tck/target/objenesis-tck-${version}.jar" https://api.bintray.com/content/easymock/distributions/objenesis/${version}/objenesis-tck-${version}.jar?publish=1 curl -v -H "X-GPG-PASSPHRASE: $gpg_passphrase" -u${bintray_user}:${bintray_api_key} -T "tck-android/target/objenesis-tck-android-${version}.apk" https://api.bintray.com/content/easymock/distributions/objenesis/${version}/objenesis-tck-android-${version}.apk?publish=1 echo "Flag the bin, tck and tck-android as 'Show in download list' in bintray" open "https://bintray.com/easymock/distributions/objenesis/${version}#files" pause echo "Add the bin, tck and tck-android jars to the release in GitHub" open "https://bintray.com/easymock/distributions/objenesis#" pause echo "Close the milestone in GitHub and create the new one" open "https://github.com/easymock/objenesis/milestones" pause echo "Sync to Maven central" open "https://bintray.com/easymock/maven/objenesis/${version}#central" pause echo echo "Job done!" echo objenesis-3.0.1/gae/000077500000000000000000000000001336222440400142305ustar00rootroot00000000000000objenesis-3.0.1/gae/README.md000066400000000000000000000004071336222440400155100ustar00rootroot00000000000000War application to deploy on GAE and test Objenesis =================================================== Dev server ---------- `mvn appengine:devserver` Deployment ---------- `mvn appengine:update` Open [objenesis.appspot.com](https://objenesis.appspot.com). objenesis-3.0.1/gae/eclipse-launch-profiles/000077500000000000000000000000001336222440400207455ustar00rootroot00000000000000objenesis-3.0.1/gae/eclipse-launch-profiles/DevAppServer.launch000066400000000000000000000014741336222440400245150ustar00rootroot00000000000000 objenesis-3.0.1/gae/eclipse-launch-profiles/UpdateApplication.launch000066400000000000000000000014711336222440400255520ustar00rootroot00000000000000 objenesis-3.0.1/gae/pom.xml000066400000000000000000000117511336222440400155520ustar00rootroot00000000000000 4.0.0 objenesis-parent org.objenesis 3.0.1 gae war Objenesis GAE War to deploy and test on GAE objenesis 2 1.9.67 2.0.9.133.v201611104 com.google.appengine appengine-api-1.0-sdk ${appengine.version} javax.servlet servlet-api 2.5 provided javax.servlet.jsp jsp-api 2.2 provided jstl jstl 1.2 org.objenesis objenesis ${project.version} provided org.objenesis objenesis-tck ${project.version} com.google.appengine appengine-testing ${appengine.version} test com.google.appengine appengine-api-stubs ${appengine.version} test ${project.build.directory}/${project.build.finalName}/WEB-INF/classes maven-deploy-plugin true maven-war-plugin true ${basedir}/src/main/webapp/WEB-INF true WEB-INF com.keyboardsamurais.maven maven-timestamp-plugin com.mycila license-maven-plugin com.google.appengine appengine-maven-plugin ${appengine.version} false ${app.version} com.google.appengine gcloud-maven-plugin ${gcloud.plugin.version} objenesis-3.0.1/gae/src/000077500000000000000000000000001336222440400150175ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/000077500000000000000000000000001336222440400157435ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/java/000077500000000000000000000000001336222440400166645ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/java/org/000077500000000000000000000000001336222440400174535ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/java/org/objenesis/000077500000000000000000000000001336222440400214345ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/java/org/objenesis/gae/000077500000000000000000000000001336222440400221705ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/java/org/objenesis/gae/JspReporter.java000066400000000000000000000152411336222440400253150ustar00rootroot00000000000000/* * Copyright 2006-2018 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.gae; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; import org.objenesis.Objenesis; import org.objenesis.tck.Candidate; import org.objenesis.tck.Reporter; import org.objenesis.tck.TCK; import javax.servlet.jsp.JspWriter; /** * Reports results from TCK in an HTML table. * * @author Henri Tremblay * @see TCK * @see Reporter */ public class JspReporter implements Reporter { private static class Result { Candidate candidate; Candidate.CandidateType type; boolean result; Exception exception; /** * @param candidate Candidate tested * @param type Type of test performed * @param result If the test is successful or not * @param exception Exception that might have occurred during the test */ public Result(Candidate candidate, Candidate.CandidateType type, boolean result, Exception exception) { this.candidate = candidate; this.type = type; this.result = result; this.exception = exception; } } private final PrintWriter summary; private final PrintWriter log; private long startTime; private int errorCount; private Objenesis objenesisStandard; private Objenesis objenesisSerializer; private Candidate currentCandidate; private final Map> results = new TreeMap<>(); private String platformDescription; /** * @param summary Output of main report. * @param log Any additional information, useful for diagnostics. */ public JspReporter(JspWriter summary, JspWriter log) { this.summary = new PrintWriter(summary); this.log = new PrintWriter(log); } @Override public void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer) { this.platformDescription = platformDescription; this.objenesisStandard = objenesisStandard; this.objenesisSerializer = objenesisSerializer; this.currentCandidate = null; this.errorCount = 0; this.results.clear(); this.startTime = System.currentTimeMillis(); } @Override public void startTest(Candidate candidate) { currentCandidate = candidate; } @Override public void result(Candidate.CandidateType type, boolean success) { addResult(type, success, null); } @Override public void exception(Candidate.CandidateType type, Exception exception) { addResult(type, false, exception); } private void addResult(Candidate.CandidateType type, boolean success, Exception exception) { if(!success) { errorCount++; } Map result = results.computeIfAbsent(currentCandidate, k -> new HashMap<>()); result.put(type, new Result(currentCandidate, type, success, exception)); } @Override public void endTests() { long totalTime = System.currentTimeMillis() - startTime; printResult(totalTime); } /** * Print the final summary report * * @param totalTime Time spent running the TCK */ private void printResult(long totalTime) { // Platform summary.println("

Running TCK on platform: " + platformDescription + "

"); // Instantiator implementations summary.println("

Instantiators used:
"); summary.println(" Objenesis standard: " + objenesisStandard.getInstantiatorOf(String.class).getClass().getName() + "
"); summary.println(" Objenesis serializer: " + objenesisSerializer.getInstantiatorOf(String.class).getClass().getName() + "
"); summary.println("

"); Collection candidateNames = new ArrayList<>(); for(Map.Entry> entry : results.entrySet()) { candidateNames.add(entry.getKey().getDescription()); } // Strategy used summary.println(""); summary.print(""); summary.print(""); summary.println(""); List exceptions = new ArrayList<>(); // Candidates for(Map.Entry> entry : results.entrySet()) { summary.print(""); Result standardResult = entry.getValue().get(Candidate.CandidateType.STANDARD); Result serializationResult = entry.getValue().get(Candidate.CandidateType.SERIALIZATION); if(standardResult == null && serializationResult == null) { continue; } if(standardResult == null) { summary.print(""); } else { summary.print(""); if(standardResult.exception != null) { exceptions.add(standardResult); } } if(serializationResult == null) { summary.print(""); } else { summary.print(""); if(serializationResult.exception != null) { exceptions.add(serializationResult); } } summary.println(); } summary.println("
Objenesis standardObjenesis serializer
" + entry.getKey().getDescription() + "N/A" + (standardResult.result ? "Y" : "n") + "N/A" + (serializationResult.result ? "Y" : "n") + "
"); // Final if(errorCount != 0) { for(Result element : exceptions) { log.println("
--- Candidate '" + element.candidate.getDescription() + "', Type '" + element.type + "' ---");
            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

"); } } } objenesis-3.0.1/gae/src/main/java/org/objenesis/gae/JspWriterListener.java000066400000000000000000000046771336222440400265100ustar00rootroot00000000000000/* * Copyright 2006-2018 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.gae; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; import org.objenesis.tck.search.SearchWorkingInstantiatorListener; import javax.servlet.jsp.JspWriter; /** * @author Henri Tremblay */ public class JspWriterListener implements SearchWorkingInstantiatorListener { private static final String PATTERN = "%s%s"; private JspWriter writer; public JspWriterListener(JspWriter out) { this.writer = out; } public void instantiatorSupported(Class c) { try { writer.println(String.format(PATTERN, c.getSimpleName() + " (" + getTypology(c) + ")", "Working!")); } catch (IOException e) { throw new RuntimeException(e); } } public void instantiatorUnsupported(Class c, Throwable t) { ByteArrayOutputStream b = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(b)); try { writer.println(String.format(PATTERN, c.getSimpleName() + " (" + getTypology(c) + ")", "KO - " + b.toString())); } catch (IOException e) { throw new RuntimeException(e); } } @Override public void instantiatorNotFound(String className, Throwable t) { ByteArrayOutputStream b = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(b)); try { writer.println(String.format(PATTERN, className + " not found", "KO - " + t)); } catch (IOException e) { throw new RuntimeException(e); } } private Typology getTypology(Class c) { Instantiator instantiatorAnn = c.getAnnotation(Instantiator.class); return instantiatorAnn == null ? Typology.UNKNOWN : instantiatorAnn.value(); } } objenesis-3.0.1/gae/src/main/webapp/000077500000000000000000000000001336222440400172215ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/webapp/WEB-INF/000077500000000000000000000000001336222440400202505ustar00rootroot00000000000000objenesis-3.0.1/gae/src/main/webapp/WEB-INF/appengine-web.xml000066400000000000000000000020131336222440400235070ustar00rootroot00000000000000 ${app.id} ${app.version} true java8 objenesis-3.0.1/gae/src/main/webapp/WEB-INF/logging.properties000066400000000000000000000020461336222440400240160ustar00rootroot00000000000000# # Copyright 2006-2018 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. # # A default java.util.logging configuration. # (All App Engine logging is through java.util.logging by default). # # To use this configuration, copy it into your application's WEB-INF # folder and add the following to your appengine-web.xml: # # # # # # Set the default logging level for all loggers to WARNING .level = WARNING objenesis-3.0.1/gae/src/main/webapp/WEB-INF/web.xml000066400000000000000000000016101336222440400215450ustar00rootroot00000000000000 objenesis-3.0.1/gae/src/main/webapp/index.jsp000066400000000000000000000044471336222440400210570ustar00rootroot00000000000000<%-- Copyright 2006-2018 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. --%> <%@ page contentType="text/html;charset=UTF-8" %> <%@ page import="java.io.PrintWriter" %> <%@ page import="java.util.Map" %> <%@ page import="java.util.TreeMap" %> <%@ page import="org.objenesis.gae.JspReporter" %> <%@ page import="org.objenesis.gae.JspWriterListener" %> <%@ page import="org.objenesis.strategy.PlatformDescription" %> <%@ page import="org.objenesis.tck.Main" %> <%@ page import="org.objenesis.tck.candidates.SerializableNoConstructor" %> <%@ page import="org.objenesis.tck.search.SearchWorkingInstantiator" %> Search Objenesis Working Instantiator

Platform description

<%= PlatformDescription.describePlatform()%>

Properties

<% for(Map.Entry property : new TreeMap<>(System.getProperties()).entrySet()) { %> <%= "" %> <% } %>
Key Value
" + property.getKey() + "" + property.getValue() + "

Supported instantiator

<% SearchWorkingInstantiator i = new SearchWorkingInstantiator(new JspWriterListener(out)); i.searchForInstantiator(SerializableNoConstructor.class); out.flush(); %>
Instantiator Result

TCK

<% JspReporter reporter = new JspReporter(out, out); try { Main.run(reporter); } catch(Exception e) { out.println("
");
    e.printStackTrace(new PrintWriter(out));
    out.println("
"); } %> objenesis-3.0.1/header.txt000066400000000000000000000011201336222440400154570ustar00rootroot00000000000000Copyright ${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. objenesis-3.0.1/main/000077500000000000000000000000001336222440400144205ustar00rootroot00000000000000objenesis-3.0.1/main/.settings/000077500000000000000000000000001336222440400163365ustar00rootroot00000000000000objenesis-3.0.1/main/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000575201336222440400233310ustar00rootroot00000000000000eclipse.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.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.5 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_annotation=0 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_method_declaration=0 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_resources_in_try=80 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.alignment_for_union_type_in_multicatch=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_import_groups=1 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.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=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_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=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.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 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.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 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_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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_try=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_semicolon_in_try_resources=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_try=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_try=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_parenthesized_expression_in_throw=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_semicolon_in_try_resources=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.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true 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.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 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_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true objenesis-3.0.1/main/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000057711336222440400230170ustar00rootroot00000000000000eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Objenesis formatter_settings_version=12 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= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=true sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true objenesis-3.0.1/main/assembly.xml000066400000000000000000000022411336222440400167600ustar00rootroot00000000000000 bin zip ${project.build.outputDirectory}/META-INF / NOTICE LICENSE ${project.build.directory} / *.jar objenesis-3.0.1/main/pom.xml000066400000000000000000000067101336222440400157410ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 objenesis Objenesis A library for instantiating Java objects http://objenesis.org maven-jar-plugin ${project.build.outputDirectory}/META-INF/MANIFEST.MF org.objenesis com.keyboardsamurais.maven maven-timestamp-plugin com.mycila license-maven-plugin maven-remote-resources-plugin org.apache.felix maven-bundle-plugin true COM.newmonics.PercClassloader;resolution:=optional, sun.misc;resolution:=optional, sun.reflect;resolution:=optional bundle-manifest process-classes manifest release maven-assembly-plugin false assembly.xml make-assembly package single objenesis-3.0.1/main/src/000077500000000000000000000000001336222440400152075ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/000077500000000000000000000000001336222440400161335ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/000077500000000000000000000000001336222440400170545ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/000077500000000000000000000000001336222440400176435ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/000077500000000000000000000000001336222440400216245ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/Objenesis.java000066400000000000000000000027621336222440400244170ustar00rootroot00000000000000/* * Copyright 2006-2018 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 Type instantiated * @param clazz Class to instantiate * @return New instance of clazz */ T 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 Type to instantiate * @param clazz Class to instantiate * @return Instantiator dedicated to the class */ ObjectInstantiator getInstantiatorOf(Class clazz); } objenesis-3.0.1/main/src/main/java/org/objenesis/ObjenesisBase.java000066400000000000000000000067471336222440400252210ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.strategy.InstantiatorStrategy; import java.util.concurrent.ConcurrentHashMap; /** * 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 Objenesis implementation to create classes */ protected final InstantiatorStrategy strategy; /** Strategy cache. Key = Class, Value = InstantiatorStrategy */ protected ConcurrentHashMap> 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 ConcurrentHashMap<>() : null; } @Override 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 T 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 */ @SuppressWarnings("unchecked") public ObjectInstantiator getInstantiatorOf(Class clazz) { if(clazz.isPrimitive()) { throw new IllegalArgumentException("Primitive types can't be instantiated in Java"); } if(cache == null) { return strategy.newInstantiatorOf(clazz); } ObjectInstantiator instantiator = cache.get(clazz.getName()); if(instantiator == null) { ObjectInstantiator newInstantiator = strategy.newInstantiatorOf(clazz); instantiator = cache.putIfAbsent(clazz.getName(), newInstantiator); if(instantiator == null) { instantiator = newInstantiator; } } return (ObjectInstantiator) instantiator; } } objenesis-3.0.1/main/src/main/java/org/objenesis/ObjenesisException.java000066400000000000000000000026061336222440400262730ustar00rootroot00000000000000/* * Copyright 2006-2018 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. * * @author Henri Tremblay */ public class ObjenesisException extends RuntimeException { private static final long serialVersionUID = -2677230016262426968L; /** * @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); } /** * @param msg Error message * @param cause Wrapped exception */ public ObjenesisException(String msg, Throwable cause) { super(msg, cause); } } objenesis-3.0.1/main/src/main/java/org/objenesis/ObjenesisHelper.java000066400000000000000000000055111336222440400255520ustar00rootroot00000000000000/* * Copyright 2006-2018 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 Type instantiated * @param clazz Class to instantiate * @return New instance of clazz */ public static T 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 Type instantiated * @param clazz Class to instantiate * @return New instance of clazz */ public static T newSerializableInstance(Class clazz) { return 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 Type to instantiate * @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 Type to instantiate * @param clazz Class to instantiate * @return Instantiator dedicated to the class */ public static ObjectInstantiator getSerializableObjectInstantiatorOf(Class clazz) { return OBJENESIS_SERIALIZER.getInstantiatorOf(clazz); } } objenesis-3.0.1/main/src/main/java/org/objenesis/ObjenesisSerializer.java000066400000000000000000000027321336222440400264460ustar00rootroot00000000000000/* * Copyright 2006-2018 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); } } objenesis-3.0.1/main/src/main/java/org/objenesis/ObjenesisStd.java000066400000000000000000000026541336222440400250720ustar00rootroot00000000000000/* * Copyright 2006-2018 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); } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/000077500000000000000000000000001336222440400243435ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/ObjectInstantiator.java000066400000000000000000000017101336222440400310130ustar00rootroot00000000000000/* * Copyright 2006-2018 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. */ T newInstance(); } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/SerializationInstantiatorHelper.java000066400000000000000000000034761336222440400335750ustar00rootroot00000000000000/* * Copyright 2006-2018 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 to instantiate * @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; } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/android/000077500000000000000000000000001336222440400257635ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/android/Android10Instantiator.java000066400000000000000000000040701336222440400327500ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android; import java.io.ObjectInputStream; import java.lang.reflect.Method; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * Instantiator for Android API level 10 and lover which creates objects without driving their * constructors, using internal methods on the Dalvik implementation of * {@link java.io.ObjectInputStream}. * * @author Piotr 'Qertoip' Włodarek */ @Instantiator(Typology.STANDARD) public class Android10Instantiator implements ObjectInstantiator { private final Class type; private final Method newStaticMethod; public Android10Instantiator(Class type) { this.type = type; newStaticMethod = getNewStaticMethod(); } public T newInstance() { try { return type.cast(newStaticMethod.invoke(null, type, Object.class)); } catch(Exception e) { throw new ObjenesisException(e); } } private static Method getNewStaticMethod() { try { Method newStaticMethod = ObjectInputStream.class.getDeclaredMethod( "newInstance", Class.class, Class.class); newStaticMethod.setAccessible(true); return newStaticMethod; } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/android/Android17Instantiator.java000066400000000000000000000053571336222440400327700ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android; import java.io.ObjectStreamClass; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * Instantiator for Android API level 11 to 17 which creates objects without driving their * constructors, using internal methods on the Dalvik implementation of {@link ObjectStreamClass}. * * @author Ian Parkinson (Google Inc.) */ @Instantiator(Typology.STANDARD) public class Android17Instantiator implements ObjectInstantiator { private final Class type; private final Method newInstanceMethod; private final Integer objectConstructorId; public Android17Instantiator(Class type) { this.type = type; newInstanceMethod = getNewInstanceMethod(); objectConstructorId = findConstructorIdForJavaLangObjectConstructor(); } public T newInstance() { try { return type.cast(newInstanceMethod.invoke(null, type, objectConstructorId)); } catch(Exception e) { throw new ObjenesisException(e); } } private static Method getNewInstanceMethod() { try { Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod( "newInstance", Class.class, Integer.TYPE); newInstanceMethod.setAccessible(true); return newInstanceMethod; } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } private static Integer findConstructorIdForJavaLangObjectConstructor() { try { Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod( "getConstructorId", Class.class); newInstanceMethod.setAccessible(true); return (Integer) newInstanceMethod.invoke(null, Object.class); } catch(RuntimeException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/android/Android18Instantiator.java000066400000000000000000000052441336222440400327640ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android; import java.io.ObjectStreamClass; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * Instantiator for Android API level 18 and higher. Same as the version 17 but the * newInstance now takes a long in parameter * * @author Henri Tremblay */ @Instantiator(Typology.STANDARD) public class Android18Instantiator implements ObjectInstantiator { private final Class type; private final Method newInstanceMethod; private final Long objectConstructorId; public Android18Instantiator(Class type) { this.type = type; newInstanceMethod = getNewInstanceMethod(); objectConstructorId = findConstructorIdForJavaLangObjectConstructor(); } public T newInstance() { try { return type.cast(newInstanceMethod.invoke(null, type, objectConstructorId)); } catch(Exception e) { throw new ObjenesisException(e); } } private static Method getNewInstanceMethod() { try { Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance", Class.class, Long.TYPE); newInstanceMethod.setAccessible(true); return newInstanceMethod; } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } private static Long findConstructorIdForJavaLangObjectConstructor() { try { Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("getConstructorId", Class.class); newInstanceMethod.setAccessible(true); return (Long) newInstanceMethod.invoke(null, Object.class); } catch(RuntimeException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { throw new ObjenesisException(e); } } } AndroidSerializationInstantiator.java000066400000000000000000000052561336222440400352750ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/android/* * Copyright 2006-2018 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.android; import java.io.ObjectStreamClass; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * {@link ObjectInstantiator} for Android which creates objects using the constructor from the first * non-serializable parent class constructor, using internal methods on the Dalvik implementation of * {@link ObjectStreamClass}. * * @author Ian Parkinson (Google Inc.) */ @Instantiator(Typology.SERIALIZATION) public class AndroidSerializationInstantiator implements ObjectInstantiator { private final Class type; private final ObjectStreamClass objectStreamClass; private final Method newInstanceMethod; public AndroidSerializationInstantiator(Class type) { this.type = type; newInstanceMethod = getNewInstanceMethod(); Method m; try { m = ObjectStreamClass.class.getMethod("lookupAny", Class.class); } catch (NoSuchMethodException e) { throw new ObjenesisException(e); } try { objectStreamClass = (ObjectStreamClass) m.invoke(null, type); } catch (IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } public T newInstance() { try { return type.cast(newInstanceMethod.invoke(objectStreamClass, type)); } catch(IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { throw new ObjenesisException(e); } } private static Method getNewInstanceMethod() { try { Method newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod( "newInstance", Class.class); newInstanceMethod.setAccessible(true); return newInstanceMethod; } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/annotations/000077500000000000000000000000001336222440400267005ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/annotations/Instantiator.java000066400000000000000000000021741336222440400322260ustar00rootroot00000000000000/* * Copyright 2006-2018 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.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * Denote that the class in an instantiator of a given type * * @author Henri Tremblay */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface Instantiator { /** * @return type of instantiator */ Typology value(); } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/annotations/Typology.java000066400000000000000000000023161336222440400313730ustar00rootroot00000000000000/* * Copyright 2006-2018 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.annotations; /** * Possible types of instantiator * @author Henri Tremblay */ public enum Typology { /** * Mark an instantiator used for standard instantiation (not calling a constructor). */ STANDARD, /** * Mark an instantiator used for serialization. */ SERIALIZATION, /** * Mark an instantiator that doesn't behave like a {@link #STANDARD} nor a {@link #SERIALIZATION} (e.g. calls a constructor, fails * all the time, etc.) */ NOT_COMPLIANT, /** * No type specified on the instantiator class */ UNKNOWN } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/000077500000000000000000000000001336222440400254245ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/AccessibleInstantiator.java000066400000000000000000000025631336222440400327320ustar00rootroot00000000000000/* * Copyright 2006-2018 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.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.NOT_COMPLIANT) public class AccessibleInstantiator extends ConstructorInstantiator { public AccessibleInstantiator(Class type) { super(type); if(constructor != null) { constructor.setAccessible(true); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/ConstructorInstantiator.java000066400000000000000000000033231336222440400332150ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 * @param Type instantiated * @see ObjectInstantiator */ @Instantiator(Typology.NOT_COMPLIANT) 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 T newInstance() { try { return constructor.newInstance((Object[]) null); } catch(Exception e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/FailingInstantiator.java000066400000000000000000000024201336222440400322360ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * The instantiator that always throws an exception. Mainly used for tests * * @author Henri Tremblay */ @Instantiator(Typology.NOT_COMPLIANT) public class FailingInstantiator implements ObjectInstantiator { public FailingInstantiator(Class type) { } /** * @return Always throwing an exception */ public T newInstance() { throw new ObjenesisException("Always failing"); } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/NewInstanceInstantiator.java000066400000000000000000000025551336222440400331140ustar00rootroot00000000000000/* * Copyright 2006-2018 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.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; import org.objenesis.instantiator.util.ClassUtils; /** * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public * constructors, but that's about it. * * @author Joe Walnes * @see ObjectInstantiator */ @Instantiator(Typology.NOT_COMPLIANT) public class NewInstanceInstantiator implements ObjectInstantiator { private final Class type; public NewInstanceInstantiator(Class type) { this.type = type; } public T newInstance() { return ClassUtils.newInstance(type); } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/NullInstantiator.java000066400000000000000000000022311336222440400315770ustar00rootroot00000000000000/* * Copyright 2006-2018 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.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * The instantiator that always return a null instance * * @author Henri Tremblay */ @Instantiator(Typology.NOT_COMPLIANT) public class NullInstantiator implements ObjectInstantiator { public NullInstantiator(Class type) { } /** * @return Always null */ public T newInstance() { return null; } } ObjectInputStreamInstantiator.java000066400000000000000000000140111336222440400342070ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.SERIALIZATION) 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]; } @Override public int read() { int result = data[pointer++]; if(pointer >= data.length) { advanceBuffer(); } return result; } @Override public int available() { return Integer.MAX_VALUE; } @Override public int read(byte[] b, int off, int len) { 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")); } } @SuppressWarnings("unchecked") public T newInstance() { try { return (T) inputStream.readObject(); } catch(ClassNotFoundException e) { throw new Error("ClassNotFoundException: " + e.getMessage()); } catch(Exception e) { throw new ObjenesisException(e); } } } ObjectStreamClassInstantiator.java000066400000000000000000000043721336222440400341660ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.SERIALIZATION) public class ObjectStreamClassInstantiator implements ObjectInstantiator { private static Method newInstanceMethod; private static void initialize() { if(newInstanceMethod == null) { try { newInstanceMethod = ObjectStreamClass.class.getDeclaredMethod("newInstance"); newInstanceMethod.setAccessible(true); } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } } private final ObjectStreamClass objStreamClass; public ObjectStreamClassInstantiator(Class type) { initialize(); objStreamClass = ObjectStreamClass.lookup(type); } @SuppressWarnings("unchecked") public T newInstance() { try { return (T) newInstanceMethod.invoke(objStreamClass); } catch(Exception e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/basic/ProxyingInstantiator.java000066400000000000000000000140601336222440400325070ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; import org.objenesis.instantiator.util.ClassDefinitionUtils; import org.objenesis.instantiator.util.ClassUtils; import static org.objenesis.instantiator.util.ClassDefinitionUtils.*; /** * This instantiator creates a class by dynamically extending it. It will skip the call to the parent constructor * in the bytecode. So that the constructor is indeed not called but you however instantiate a child class, not * the actual class. The class loader will normally throw a {@code VerifyError} is you do that. However, using * {@code -Xverify:none} should make it work * * @author Henri Tremblay */ @Instantiator(Typology.STANDARD) public class ProxyingInstantiator implements ObjectInstantiator { private static final int INDEX_CLASS_THIS = 1; private static final int INDEX_CLASS_SUPERCLASS = 2; private static final int INDEX_UTF8_CONSTRUCTOR_NAME = 3; private static final int INDEX_UTF8_CONSTRUCTOR_DESC = 4; private static final int INDEX_UTF8_CODE_ATTRIBUTE = 5; private static final int INDEX_UTF8_CLASS = 7; private static final int INDEX_UTF8_SUPERCLASS = 8; private static final int CONSTANT_POOL_COUNT = 9; private static final byte[] CODE = { OPS_aload_0, OPS_return}; private static final int CODE_ATTRIBUTE_LENGTH = 12 + CODE.length; private static final String SUFFIX = "$$$Objenesis"; private static final String CONSTRUCTOR_NAME = ""; private static final String CONSTRUCTOR_DESC = "()V"; private final Class newType; public ProxyingInstantiator(Class type) { byte[] classBytes = writeExtendingClass(type); try { newType = ClassDefinitionUtils.defineClass(type.getName() + SUFFIX, classBytes, type, type.getClassLoader()); } catch (Exception e) { throw new ObjenesisException(e); } } public T newInstance() { return ClassUtils.newInstance(newType); } /** * Will generate the bytes for a class extending the type passed in parameter. This class will * only have an empty default constructor * * @param type type to extend * @return the byte for the class * @throws ObjenesisException is something goes wrong */ private static byte[] writeExtendingClass(Class type) { String parentClazz = ClassUtils.classNameToInternalClassName(type.getName()); String clazz = parentClazz + SUFFIX; ByteArrayOutputStream bIn = new ByteArrayOutputStream(1000); // 1000 should be large enough to fit the entire class try(DataOutputStream in = new DataOutputStream(bIn)) { in.write(MAGIC); in.write(VERSION); in.writeShort(CONSTANT_POOL_COUNT); // set all the constant pool here // 1. class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_CLASS); // 2. super class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_SUPERCLASS); // 3. default constructor name in.writeByte(CONSTANT_Utf8); in.writeUTF(CONSTRUCTOR_NAME); // 4. default constructor description in.writeByte(CONSTANT_Utf8); in.writeUTF(CONSTRUCTOR_DESC); // 5. Code in.writeByte(CONSTANT_Utf8); in.writeUTF("Code"); // 6. Class name in.writeByte(CONSTANT_Utf8); in.writeUTF("L" + clazz + ";"); // 7. Class name (again) in.writeByte(CONSTANT_Utf8); in.writeUTF(clazz); // 8. Superclass name in.writeByte(CONSTANT_Utf8); in.writeUTF(parentClazz); // end of constant pool // access flags: We want public, ACC_SUPER is always there in.writeShort(ACC_PUBLIC | ACC_SUPER); // this class index in the constant pool in.writeShort(INDEX_CLASS_THIS); // super class index in the constant pool in.writeShort(INDEX_CLASS_SUPERCLASS); // interfaces implemented count (we have none) in.writeShort(0); // fields count (we have none) in.writeShort(0); // methods count (we have one: the default constructor) in.writeShort(1); // default constructor method_info in.writeShort(ACC_PUBLIC); in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME); // index of the method name () in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC); // index of the description in.writeShort(1); // number of attributes: only one, the code // code attribute of the default constructor in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE); in.writeInt(CODE_ATTRIBUTE_LENGTH); // attribute length in.writeShort(1); // max_stack in.writeShort(1); // max_locals in.writeInt(CODE.length); // code length in.write(CODE); in.writeShort(0); // exception_table_length = 0 in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable // class attributes in.writeShort(0); // none. No need to have a source file attribute } catch (IOException e) { throw new ObjenesisException(e); } return bIn.toByteArray(); } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/gcj/000077500000000000000000000000001336222440400251065ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiator.java000066400000000000000000000030651336222440400307600ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.STANDARD) public class GCJInstantiator extends GCJInstantiatorBase { public GCJInstantiator(Class type) { super(type); } @Override public T newInstance() { try { return type.cast(newObjectMethod.invoke(dummyStream, type, Object.class)); } catch(RuntimeException | IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/gcj/GCJInstantiatorBase.java000066400000000000000000000037451336222440400315600ustar00rootroot00000000000000/* * Copyright 2006-2018 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 { static Method newObjectMethod = null; 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", Class.class, Class.class); newObjectMethod.setAccessible(true); dummyStream = new DummyStream(); } catch(RuntimeException | NoSuchMethodException | IOException e) { throw new ObjenesisException(e); } } } protected final Class type; public GCJInstantiatorBase(Class type) { this.type = type; initialize(); } public abstract T newInstance(); } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/gcj/GCJSerializationInstantiator.java000066400000000000000000000034171336222440400335170ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.SERIALIZATION) public class GCJSerializationInstantiator extends GCJInstantiatorBase { private final Class superType; public GCJSerializationInstantiator(Class type) { super(type); this.superType = SerializationInstantiatorHelper.getNonSerializableSuperClass(type); } @Override public T newInstance() { try { return type.cast(newObjectMethod.invoke(dummyStream, type, superType)); } catch(Exception e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/perc/000077500000000000000000000000001336222440400252745ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/perc/PercInstantiator.java000066400000000000000000000037521336222440400314370ustar00rootroot00000000000000/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.STANDARD) 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", Class.class, Boolean.TYPE); newInstanceMethod.setAccessible(true); } catch(RuntimeException | NoSuchMethodException e) { throw new ObjenesisException(e); } } @SuppressWarnings("unchecked") public T newInstance() { try { return (T) newInstanceMethod.invoke(null, typeArgs); } catch (Exception e) { throw new ObjenesisException(e); } } } PercSerializationInstantiator.java000066400000000000000000000064101336222440400341100ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/perc/* * Copyright 2006-2018 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; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.SERIALIZATION) public class PercSerializationInstantiator implements ObjectInstantiator { private Object[] typeArgs; private final 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", Class.class, Object.class, percMethodClass); newInstanceMethod.setAccessible(true); // Create invoke params Class percClassClass = Class.forName("COM.newmonics.PercClassLoader.PercClass"); Method getPercClassMethod = percClassClass.getDeclaredMethod("getPercClass", Class.class); Object someObject = getPercClassMethod.invoke(null, unserializableType); Method findMethodMethod = someObject.getClass().getDeclaredMethod("findMethod", String.class); Object percMethod = findMethodMethod.invoke(someObject, "()V"); typeArgs = new Object[] {unserializableType, type, percMethod}; } catch(ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } @SuppressWarnings("unchecked") public T newInstance() { try { return (T) newInstanceMethod.invoke(null, typeArgs); } catch(IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/000077500000000000000000000000001336222440400251505ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/MagicInstantiator.java000066400000000000000000000245551336222440400314460ustar00rootroot00000000000000/* * Copyright 2006-2018 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.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; import org.objenesis.instantiator.util.ClassDefinitionUtils; import org.objenesis.instantiator.util.ClassUtils; import static org.objenesis.instantiator.util.ClassDefinitionUtils.*; /** * This instantiator will correctly bypass the constructors by instantiating the class using the default * constructor from Object. It will be allowed to do so by extending {@code MagicAccessorImpl} which prevents * its children to be verified by the class loader * * @author Henri Tremblay */ @Instantiator(Typology.STANDARD) public class MagicInstantiator implements ObjectInstantiator { private static final String MAGIC_ACCESSOR = getMagicClass(); private static final int INDEX_CLASS_THIS = 1; private static final int INDEX_CLASS_SUPERCLASS = 2; private static final int INDEX_UTF8_CONSTRUCTOR_NAME = 3; private static final int INDEX_UTF8_CONSTRUCTOR_DESC = 4; private static final int INDEX_UTF8_CODE_ATTRIBUTE = 5; private static final int INDEX_UTF8_INSTANTIATOR_CLASS = 7; private static final int INDEX_UTF8_SUPERCLASS = 8; private static final int INDEX_CLASS_INTERFACE = 9; private static final int INDEX_UTF8_INTERFACE = 10; private static final int INDEX_UTF8_NEWINSTANCE_NAME = 11; private static final int INDEX_UTF8_NEWINSTANCE_DESC = 12; private static final int INDEX_METHODREF_OBJECT_CONSTRUCTOR = 13; private static final int INDEX_CLASS_OBJECT = 14; private static final int INDEX_UTF8_OBJECT = 15; private static final int INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR = 16; private static final int INDEX_CLASS_TYPE = 17; private static final int INDEX_UTF8_TYPE = 18; private static final int CONSTANT_POOL_COUNT = 19; private static final byte[] CONSTRUCTOR_CODE = { OPS_aload_0, OPS_invokespecial, 0, INDEX_METHODREF_OBJECT_CONSTRUCTOR, OPS_return}; private static final int CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH = 12 + CONSTRUCTOR_CODE.length; private static final byte[] NEWINSTANCE_CODE = { OPS_new, 0, INDEX_CLASS_TYPE, OPS_dup, OPS_invokespecial, 0, INDEX_METHODREF_OBJECT_CONSTRUCTOR, OPS_areturn}; private static final int NEWINSTANCE_CODE_ATTRIBUTE_LENGTH = 12 + NEWINSTANCE_CODE.length; private static final String CONSTRUCTOR_NAME = ""; private static final String CONSTRUCTOR_DESC = "()V"; private final ObjectInstantiator instantiator; public MagicInstantiator(Class type) { instantiator = newInstantiatorOf(type); } /** * Get the underlying instantiator. * * {@link MagicInstantiator} is a wrapper around another object * which implements {@link ObjectInstantiator} interface. * This method exposes that instantiator. * * @return the underlying instantiator */ public ObjectInstantiator getInstantiator() { return instantiator; } private ObjectInstantiator newInstantiatorOf(Class type) { String suffix = type.getSimpleName(); String className = getClass().getName() + "$$$" + suffix; Class> clazz = ClassUtils.getExistingClass(getClass().getClassLoader(), className); if(clazz == null) { byte[] classBytes = writeExtendingClass(type, className); try { clazz = ClassDefinitionUtils.defineClass(className, classBytes, type, getClass().getClassLoader()); } catch (Exception e) { throw new ObjenesisException(e); } } return ClassUtils.newInstance(clazz); } /** * Will generate the bytes for a class extending the type passed in parameter. This class will * only have an empty default constructor * * @param type type to extend * @param className name of the wrapped instantiator class * @return the byte for the class * @throws ObjenesisException is something goes wrong */ private byte[] writeExtendingClass(Class type, String className) { String clazz = ClassUtils.classNameToInternalClassName(className); ByteArrayOutputStream bIn = new ByteArrayOutputStream(1000); // 1000 should be large enough to fit the entire class try(DataOutputStream in = new DataOutputStream(bIn)) { in.write(MAGIC); in.write(VERSION); in.writeShort(CONSTANT_POOL_COUNT); // set all the constant pool here // 1. class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_INSTANTIATOR_CLASS); // 2. super class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_SUPERCLASS); // 3. default constructor name in.writeByte(CONSTANT_Utf8); in.writeUTF(CONSTRUCTOR_NAME); // 4. default constructor description in.writeByte(CONSTANT_Utf8); in.writeUTF(CONSTRUCTOR_DESC); // 5. Code in.writeByte(CONSTANT_Utf8); in.writeUTF("Code"); // 6. Class name in.writeByte(CONSTANT_Utf8); in.writeUTF("L" + clazz + ";"); // 7. Class name (again) in.writeByte(CONSTANT_Utf8); in.writeUTF(clazz); // 8. Superclass name in.writeByte(CONSTANT_Utf8); // in.writeUTF("java/lang/Object"); in.writeUTF(MAGIC_ACCESSOR); // 9. ObjectInstantiator interface in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_INTERFACE); // 10. ObjectInstantiator name in.writeByte(CONSTANT_Utf8); in.writeUTF(ObjectInstantiator.class.getName().replace('.', '/')); // 11. newInstance name in.writeByte(CONSTANT_Utf8); in.writeUTF("newInstance"); // 12. newInstance desc in.writeByte(CONSTANT_Utf8); in.writeUTF("()Ljava/lang/Object;"); // 13. Methodref to the Object constructor in.writeByte(CONSTANT_Methodref); in.writeShort(INDEX_CLASS_OBJECT); in.writeShort(INDEX_NAMEANDTYPE_DEFAULT_CONSTRUCTOR); // 14. Object class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_OBJECT); // 15. Object class name in.writeByte(CONSTANT_Utf8); in.writeUTF("java/lang/Object"); // 16. Default constructor name and type in.writeByte(CONSTANT_NameAndType); in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME); in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC); // 17. Type to instantiate class in.writeByte(CONSTANT_Class); in.writeShort(INDEX_UTF8_TYPE); // 18. Type to instantiate name in.writeByte(CONSTANT_Utf8); in.writeUTF(ClassUtils.classNameToInternalClassName(type.getName())); // end of constant pool // access flags: We want public, ACC_SUPER is always there in.writeShort(ACC_PUBLIC | ACC_SUPER | ACC_FINAL); // this class index in the constant pool in.writeShort(INDEX_CLASS_THIS); // super class index in the constant pool in.writeShort(INDEX_CLASS_SUPERCLASS); // interfaces implemented count (we have none) in.writeShort(1); in.writeShort(INDEX_CLASS_INTERFACE); // fields count (we have none) in.writeShort(0); // method count (we have two: the default constructor and newInstance) in.writeShort(2); // default constructor method_info in.writeShort(ACC_PUBLIC); in.writeShort(INDEX_UTF8_CONSTRUCTOR_NAME); // index of the method name () in.writeShort(INDEX_UTF8_CONSTRUCTOR_DESC); // index of the description in.writeShort(1); // number of attributes: only one, the code // code attribute of the default constructor in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE); in.writeInt(CONSTRUCTOR_CODE_ATTRIBUTE_LENGTH); // attribute length in.writeShort(0); // max_stack in.writeShort(1); // max_locals in.writeInt(CONSTRUCTOR_CODE.length); // code length in.write(CONSTRUCTOR_CODE); in.writeShort(0); // exception_table_length = 0 in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable // newInstance method_info in.writeShort(ACC_PUBLIC); in.writeShort(INDEX_UTF8_NEWINSTANCE_NAME); // index of the method name (newInstance) in.writeShort(INDEX_UTF8_NEWINSTANCE_DESC); // index of the description in.writeShort(1); // number of attributes: only one, the code // code attribute of newInstance in.writeShort(INDEX_UTF8_CODE_ATTRIBUTE); in.writeInt(NEWINSTANCE_CODE_ATTRIBUTE_LENGTH); // attribute length in.writeShort(2); // max_stack in.writeShort(1); // max_locals in.writeInt(NEWINSTANCE_CODE.length); // code length in.write(NEWINSTANCE_CODE); in.writeShort(0); // exception_table_length = 0 in.writeShort(0); // attributes count = 0, no need to have LineNumberTable and LocalVariableTable // class attributes in.writeShort(0); // none. No need to have a source file attribute } catch (IOException e) { throw new ObjenesisException(e); } return bIn.toByteArray(); } public T newInstance() { return instantiator.newInstance(); } private static String getMagicClass() { try { Class.forName("sun.reflect.MagicAccessorImpl", false, MagicInstantiator.class.getClassLoader()); return "sun/reflect/MagicAccessorImpl"; } catch (ClassNotFoundException e) { return "jdk/internal/reflect/MagicAccessorImpl"; } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/SunReflectionFactoryHelper.java000066400000000000000000000055011336222440400332640ustar00rootroot00000000000000/* * Copyright 2006-2018 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 java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; /** * Helper methods providing access to {@link sun.reflect.ReflectionFactory} via reflection, for use * by the {@link ObjectInstantiator}s that use it. * * @author Henri Tremblay */ @SuppressWarnings("restriction") class SunReflectionFactoryHelper { @SuppressWarnings("unchecked") public static Constructor newConstructorForSerialization(Class type, Constructor constructor) { Class reflectionFactoryClass = getReflectionFactoryClass(); Object reflectionFactory = createReflectionFactory(reflectionFactoryClass); Method newConstructorForSerializationMethod = getNewConstructorForSerializationMethod( reflectionFactoryClass); try { return (Constructor) newConstructorForSerializationMethod.invoke( reflectionFactory, type, constructor); } catch(IllegalArgumentException | IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } private static Class getReflectionFactoryClass() { try { return Class.forName("sun.reflect.ReflectionFactory"); } catch(ClassNotFoundException e) { throw new ObjenesisException(e); } } private static Object createReflectionFactory(Class reflectionFactoryClass) { try { Method method = reflectionFactoryClass.getDeclaredMethod( "getReflectionFactory"); return method.invoke(null); } catch(NoSuchMethodException | IllegalAccessException | InvocationTargetException | IllegalArgumentException e) { throw new ObjenesisException(e); } } private static Method getNewConstructorForSerializationMethod(Class reflectionFactoryClass) { try { return reflectionFactoryClass.getDeclaredMethod( "newConstructorForSerialization", Class.class, Constructor.class); } catch(NoSuchMethodException e) { throw new ObjenesisException(e); } } } SunReflectionFactoryInstantiator.java000066400000000000000000000043211336222440400344440ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/* * Copyright 2006-2018 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 org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.STANDARD) public class SunReflectionFactoryInstantiator implements ObjectInstantiator { private final Constructor mungedConstructor; public SunReflectionFactoryInstantiator(Class type) { Constructor javaLangObjectConstructor = getJavaLangObjectConstructor(); mungedConstructor = SunReflectionFactoryHelper.newConstructorForSerialization( type, javaLangObjectConstructor); mungedConstructor.setAccessible(true); } public T newInstance() { try { return mungedConstructor.newInstance((Object[]) null); } catch(Exception e) { throw new ObjenesisException(e); } } private static Constructor getJavaLangObjectConstructor() { try { return Object.class.getConstructor((Class[]) null); } catch(NoSuchMethodException e) { throw new ObjenesisException(e); } } } SunReflectionFactorySerializationInstantiator.java000066400000000000000000000052041336222440400372030ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/* * Copyright 2006-2018 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 org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * 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 */ @Instantiator(Typology.SERIALIZATION) public class SunReflectionFactorySerializationInstantiator implements ObjectInstantiator { private final Constructor mungedConstructor; public SunReflectionFactorySerializationInstantiator(Class type) { Class nonSerializableAncestor = SerializationInstantiatorHelper .getNonSerializableSuperClass(type); Constructor nonSerializableAncestorConstructor; try { nonSerializableAncestorConstructor = nonSerializableAncestor .getDeclaredConstructor((Class[]) null); } catch(NoSuchMethodException e) { throw new ObjenesisException(new NotSerializableException(type+" has no suitable superclass constructor")); } mungedConstructor = SunReflectionFactoryHelper.newConstructorForSerialization( type, nonSerializableAncestorConstructor); mungedConstructor.setAccessible(true); } public T newInstance() { try { return mungedConstructor.newInstance((Object[]) null); } catch(Exception e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/sun/UnsafeFactoryInstantiator.java000066400000000000000000000034051336222440400331660ustar00rootroot00000000000000/* * Copyright 2006-2018 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 sun.misc.Unsafe; import org.objenesis.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; import org.objenesis.instantiator.util.UnsafeUtils; /** * Instantiates an object, WITHOUT calling it's constructor, using * {@code sun.misc.Unsafe.allocateInstance()}. Unsafe and its methods are implemented by most * modern JVMs. * * @author Henri Tremblay * @see ObjectInstantiator */ @SuppressWarnings("restriction") @Instantiator(Typology.STANDARD) public class UnsafeFactoryInstantiator implements ObjectInstantiator { private final Unsafe unsafe; private final Class type; public UnsafeFactoryInstantiator(Class type) { this.unsafe = UnsafeUtils.getUnsafe(); // retrieve it to fail right away at instantiator creation if not there this.type = type; } public T newInstance() { try { return type.cast(unsafe.allocateInstance(type)); } catch (InstantiationException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/util/000077500000000000000000000000001336222440400253205ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/util/ClassDefinitionUtils.java000066400000000000000000000133461336222440400322710ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.security.ProtectionDomain; /** * Helper class for ProxyObjectInstantiator. We can see the details of a class specification * here * * @author Henri Tremblay */ public final class ClassDefinitionUtils { public static final byte OPS_aload_0 = 42; public static final byte OPS_invokespecial = -73; // has two bytes parameters public static final byte OPS_return = -79; public static final byte OPS_new = -69; public static final byte OPS_dup = 89; public static final byte OPS_areturn = -80; public static final int CONSTANT_Utf8 = 1; public static final int CONSTANT_Integer = 3; public static final int CONSTANT_Float = 4; public static final int CONSTANT_Long = 5; public static final int CONSTANT_Double = 6; public static final int CONSTANT_Class = 7; public static final int CONSTANT_String = 8; public static final int CONSTANT_Fieldref = 9; public static final int CONSTANT_Methodref = 10; public static final int CONSTANT_InterfaceMethodref = 11; public static final int CONSTANT_NameAndType = 12; public static final int CONSTANT_MethodHandle = 15; public static final int CONSTANT_MethodType = 16; public static final int CONSTANT_InvokeDynamic = 18; public static final int ACC_PUBLIC = 0x0001; // Declared public; may be accessed from outside its package. public static final int ACC_FINAL = 0x0010; // Declared final; no subclasses allowed. public static final int ACC_SUPER = 0x0020; // Treat superclass methods specially when invoked by the invokespecial instruction. public static final int ACC_INTERFACE = 0x0200; // Is an interface, not a class. public static final int ACC_ABSTRACT = 0x0400; // Declared abstract; must not be instantiated. public static final int ACC_SYNTHETIC = 0x1000; // Declared synthetic; not present in the source code. public static final int ACC_ANNOTATION = 0x2000; // Declared as an annotation type. public static final int ACC_ENUM = 0x4000; // Declared as an enum type. public static final byte[] MAGIC = { (byte) 0xca, (byte) 0xfe, (byte) 0xba, (byte) 0xbe }; public static final byte[] VERSION = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x31 }; // minor_version, major_version (Java 5) private ClassDefinitionUtils() { } private static final ProtectionDomain PROTECTION_DOMAIN; static { PROTECTION_DOMAIN = AccessController.doPrivileged((PrivilegedAction) ClassDefinitionUtils.class::getProtectionDomain); } /** * Define a class in the provided class loader from the array of bytes. Inspired by cglib * ReflectUtils.defineClass * * @param type of the class returned * @param className class name in the format org.objenesis.MyClass * @param b bytes representing the class * @param neighbor a class in the same package as the loaded class * @param loader the class loader where the class will be loaded * @return the newly loaded class * @throws Exception whenever something goes wrong */ @SuppressWarnings("unchecked") public static Class defineClass(String className, byte[] b, Class neighbor, ClassLoader loader) throws Exception { Class c = (Class) DefineClassHelper.defineClass(className, b, 0, b.length, neighbor, loader, PROTECTION_DOMAIN); // Force static initializers to run. Class.forName(className, true, loader); return c; } /** * Read the bytes of a class from the classpath * * @param className full class name including the package * @return the bytes representing the class * @throws IllegalArgumentException if the class is longer than 2500 bytes * @throws IOException if we fail to read the class */ public static byte[] readClass(String className) throws IOException { // convert to a resource className = ClassUtils.classNameToResource(className); byte[] b = new byte[2500]; // I'm assuming that I'm reading class that are not too big int length; try (InputStream in = ClassDefinitionUtils.class.getClassLoader().getResourceAsStream(className)) { length = in.read(b); } if(length >= 2500) { throw new IllegalArgumentException("The class is longer that 2500 bytes which is currently unsupported"); } byte[] copy = new byte[length]; System.arraycopy(b, 0, copy, 0, length); return copy; } /** * Write all class bytes to a file. * * @param fileName file where the bytes will be written * @param bytes bytes representing the class * @throws IOException if we fail to write the class */ public static void writeClass(String fileName, byte[] bytes) throws IOException { try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(fileName))) { out.write(bytes); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/util/ClassUtils.java000066400000000000000000000051341336222440400302540ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import org.objenesis.ObjenesisException; /** * Helper class for to play with classes. It contains everything needed to play with a class * except the dodgy (Java 8) code you will find in {@link ClassDefinitionUtils}. * * @author Henri Tremblay */ public final class ClassUtils { private ClassUtils() { } /** * Will convert a class name to its name in the class definition format (e.g {@code org.objenesis.EmptyClass} * becomes {@code org/objenesis/EmptyClass}) * * @param className full class name including the package * @return the internal name */ public static String classNameToInternalClassName(String className) { return className.replace('.', '/'); } /** * Will convert a class name to its class loader resource name (e.g {@code org.objenesis.EmptyClass} * becomes {@code org/objenesis/EmptyClass.class}) * * @param className full class name including the package * @return the resource name */ public static String classNameToResource(String className) { return classNameToInternalClassName(className) + ".class"; } /** * Check if this class already exists in the class loader and return it if it does * * @param type of the class returned * @param classLoader Class loader where to search the class * @param className Class name with full path * @return the class if it already exists or null */ @SuppressWarnings("unchecked") public static Class getExistingClass(ClassLoader classLoader, String className) { try { return (Class) Class.forName(className, true, classLoader); } catch (ClassNotFoundException e) { return null; } } @SuppressWarnings("deprecation") public static T newInstance(Class clazz) { try { return clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/util/DefineClassHelper.java000066400000000000000000000136271336222440400315140ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import sun.misc.Unsafe; import org.objenesis.ObjenesisException; import org.objenesis.strategy.PlatformDescription; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; import java.security.ProtectionDomain; /** * Java 11+ removed sun.misc.Unsafe.defineClass. This class bridges the gap to work from Java 1.8 up to 11. *

* It was inspired from javassist. * * @author Henri Tremblay */ public final class DefineClassHelper { private static abstract class Helper { abstract Class defineClass(String name, byte[] b, int off, int len, Class neighbor, ClassLoader loader, ProtectionDomain protectionDomain); } private static class Java8 extends Helper { private final MethodHandle defineClass = defineClass(); private MethodHandle defineClass() { MethodType mt = MethodType.methodType(Class.class, String.class, byte[].class, int.class, int.class, ClassLoader.class, ProtectionDomain.class); MethodHandle m; try { m = MethodHandles.publicLookup().findVirtual(Unsafe.class, "defineClass", mt); } catch(NoSuchMethodException | IllegalAccessException e) { throw new ObjenesisException(e); } Unsafe unsafe = UnsafeUtils.getUnsafe(); return m.bindTo(unsafe); } @Override Class defineClass(String className, byte[] b, int off, int len, Class neighbor, ClassLoader loader, ProtectionDomain protectionDomain) { try { return (Class) defineClass.invokeExact(className, b, off, len, loader, protectionDomain); } catch (Throwable e) { if(e instanceof Error) { throw (Error) e; } if(e instanceof RuntimeException) { throw (RuntimeException) e; } throw new ObjenesisException(e); } } } private static class Java11 extends Helper { private final Class module = module(); private final MethodHandles.Lookup lookup = MethodHandles.lookup(); private final MethodHandle getModule = getModule(); private final MethodHandle addReads = addReads(); private final MethodHandle privateLookupIn = privateLookupIn(); private final MethodHandle defineClass = defineClass(); private Class module() { try { return Class.forName("java.lang.Module"); } catch (ClassNotFoundException e) { throw new ObjenesisException(e); } } private MethodHandle getModule() { try { return lookup.findVirtual(Class.class, "getModule", MethodType.methodType(module)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new ObjenesisException(e); } } private MethodHandle addReads() { try { return lookup.findVirtual(module, "addReads", MethodType.methodType(module, module)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new ObjenesisException(e); } } private MethodHandle privateLookupIn() { try { return lookup.findStatic(MethodHandles.class, "privateLookupIn", MethodType.methodType(MethodHandles.Lookup.class, Class.class, MethodHandles.Lookup.class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new ObjenesisException(e); } } private MethodHandle defineClass() { try { return lookup.findVirtual(MethodHandles.Lookup.class, "defineClass", MethodType.methodType(Class.class, byte[].class)); } catch (NoSuchMethodException | IllegalAccessException e) { throw new ObjenesisException(e); } } @Override Class defineClass(String className, byte[] b, int off, int len, Class neighbor, ClassLoader loader, ProtectionDomain protectionDomain) { try { Object module = getModule.invokeWithArguments(DefineClassHelper.class); Object neighborModule = getModule.invokeWithArguments(neighbor); addReads.invokeWithArguments(module, neighborModule); MethodHandles.Lookup prvlookup = (MethodHandles.Lookup) privateLookupIn.invokeExact(neighbor, lookup); return (Class) defineClass.invokeExact(prvlookup, b); } catch (Throwable e) { throw new ObjenesisException(neighbor.getName() + " has no permission to define the class", e); } } } // Java 11+ removed sun.misc.Unsafe.defineClass, so we fallback to invoking defineClass on // ClassLoader until we have an implementation that uses MethodHandles.Lookup.defineClass private static final Helper privileged = PlatformDescription.isAfterJava11() ? new Java11() : new Java8(); public static Class defineClass(String name, byte[] b, int off, int len, Class neighbor, ClassLoader loader, ProtectionDomain protectionDomain) { return privileged.defineClass(name, b, off, len, neighbor, loader, protectionDomain); } private DefineClassHelper() {} } objenesis-3.0.1/main/src/main/java/org/objenesis/instantiator/util/UnsafeUtils.java000066400000000000000000000026031336222440400304260ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import java.lang.reflect.Field; import org.objenesis.ObjenesisException; import sun.misc.Unsafe; /** * Helper class basically allowing to get access to {@code sun.misc.Unsafe} * * @author Henri Tremblay */ public final class UnsafeUtils { private static final Unsafe unsafe; static { Field f; try { f = Unsafe.class.getDeclaredField("theUnsafe"); } catch (NoSuchFieldException e) { throw new ObjenesisException(e); } f.setAccessible(true); try { unsafe = (Unsafe) f.get(null); } catch (IllegalAccessException e) { throw new ObjenesisException(e); } } private UnsafeUtils() {} public static Unsafe getUnsafe() { return unsafe; } } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/000077500000000000000000000000001336222440400234665ustar00rootroot00000000000000objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/BaseInstantiatorStrategy.java000066400000000000000000000015521336222440400313310ustar00rootroot00000000000000/* * Copyright 2006-2018 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. Only implements {@link InstantiatorStrategy} * * @author Henri Tremblay */ public abstract class BaseInstantiatorStrategy implements InstantiatorStrategy { } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/InstantiatorStrategy.java000066400000000000000000000021441336222440400305340ustar00rootroot00000000000000/* * Copyright 2006-2018 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 to instantiate * @param type Class that will be instantiated * @return Dedicated instantiator */ ObjectInstantiator newInstantiatorOf(Class type); } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/PlatformDescription.java000066400000000000000000000147741336222440400303360ustar00rootroot00000000000000/* * Copyright 2006-2018 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.lang.reflect.Field; import org.objenesis.ObjenesisException; /** * List of constants describing the currently used platform. * * @author Henri Tremblay */ public final class PlatformDescription { /** JVM_NAME prefix for GCJ */ public static final String GNU = "GNU libgcj"; /** JVM_NAME prefix for Java HotSpot */ public static final String HOTSPOT = "Java HotSpot"; /** * JVM_NAME prefix for Java HotSpot * * @deprecated Use {@link #HOTSPOT} instead */ @Deprecated public static final String SUN = HOTSPOT; /** JVM_NAME prefix for the OpenJDK */ public static final String OPENJDK = "OpenJDK"; /** JVM_NAME prefix for Aonix PERC */ public static final String PERC = "PERC"; /** JVM_NAME prefix for Dalvik/Android */ public static final String DALVIK = "Dalvik"; /** Java specification version */ public static final String SPECIFICATION_VERSION = System .getProperty("java.specification.version"); /** JVM version */ public static final String VM_VERSION = System.getProperty("java.runtime.version"); /** JVM version */ public static final String VM_INFO = System.getProperty("java.vm.info"); /** VM vendor version */ public static final String VENDOR_VERSION = System.getProperty("java.vm.version"); /** VM vendor name */ public static final String VENDOR = System.getProperty("java.vm.vendor"); /** JVM name */ public static final String JVM_NAME = System.getProperty("java.vm.name"); /** Android version. Will be 0 for none android platform */ public static final int ANDROID_VERSION = getAndroidVersion(); /** Flag telling if this version of Android is based on the OpenJDK */ public static final boolean IS_ANDROID_OPENJDK = getIsAndroidOpenJDK(); /** Google App Engine version or null is we are not on GAE */ public static final String GAE_VERSION = getGaeRuntimeVersion(); /** * Describes the platform. Outputs Java version and vendor. * * @return Description of the current platform */ public static String describePlatform() { String desc = "Java " + SPECIFICATION_VERSION + " (" + "VM vendor name=\"" + VENDOR + "\", " + "VM vendor version=" + VENDOR_VERSION + ", " + "JVM name=\"" + JVM_NAME + "\", " + "JVM version=" + VM_VERSION + ", " + "JVM info=" + VM_INFO; // Add the API level if it's an Android platform if(ANDROID_VERSION != 0) { desc += ", API level=" + ANDROID_VERSION; } desc += ")"; return desc; } /** * Check if the current JVM is of the type passed in parameter. Normally, this will be a constant * from this class. We basically do * System.getProperty("java.vm.name").startWith(name). * * @param name jvm name we are looking for * @return if it's the requested JVM */ public static boolean isThisJVM(String name) { return JVM_NAME.startsWith(name); } /** * Check if this JVM is an Android JVM based on OpenJDK. * * @return if it's an Android version based on the OpenJDK. Will return false if this JVM isn't an Android JVM at all */ public static boolean isAndroidOpenJDK() { return IS_ANDROID_OPENJDK; } private static boolean getIsAndroidOpenJDK() { if(getAndroidVersion() == 0) { return false; // Not android at all } // Sadly, Android N is still API 23. So we can't base ourselves on the API level to know if it is an OpenJDK // version or not String bootClasspath = System.getProperty("java.boot.class.path"); return bootClasspath != null && bootClasspath.toLowerCase().contains("core-oj.jar"); } /** * Tells if the current JVM is running Java 9 or above * * @return if the current JVM is Java 9 or above */ public static boolean isAfterJigsaw() { String version = PlatformDescription.SPECIFICATION_VERSION; return version.indexOf('.') < 0; // No dot means the version is 9, 10, 11, ... not 1.6, 1.7, 1.8 } /** * Tells if the current JVM is running Java 11 or above * * @return if the current JVM is Java 11 or above */ public static boolean isAfterJava11() { if(!isAfterJigsaw()) { return false; } int version = Integer.parseInt(PlatformDescription.SPECIFICATION_VERSION); return version >= 11; } public static boolean isGoogleAppEngine() { return GAE_VERSION != null; } private static String getGaeRuntimeVersion() { return System.getProperty("com.google.appengine.runtime.version"); } private static int getAndroidVersion() { if(!isThisJVM(DALVIK)) { return 0; } return getAndroidVersion0(); } private static int getAndroidVersion0() { Class clazz; try { clazz = Class.forName("android.os.Build$VERSION"); } catch(ClassNotFoundException e) { throw new ObjenesisException(e); } Field field; try { field = clazz.getField("SDK_INT"); } catch(NoSuchFieldException e) { // Might be a really old API (before 4), go for SDK return getOldAndroidVersion(clazz); } int version; try { version = (Integer) field.get(null); } catch(IllegalAccessException e) { throw new RuntimeException(e); } return version; } private static int getOldAndroidVersion(Class versionClass) { Field field; try { field = versionClass.getField("SDK"); } catch(NoSuchFieldException e) { throw new ObjenesisException(e); } String version; try { version = (String) field.get(null); } catch(IllegalAccessException e) { throw new RuntimeException(e); } return Integer.parseInt(version); } private PlatformDescription() { } } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/SerializingInstantiatorStrategy.java000066400000000000000000000064541336222440400327450ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android.AndroidSerializationInstantiator; import org.objenesis.instantiator.basic.ObjectInputStreamInstantiator; import org.objenesis.instantiator.basic.ObjectStreamClassInstantiator; import org.objenesis.instantiator.gcj.GCJSerializationInstantiator; import org.objenesis.instantiator.perc.PercSerializationInstantiator; import org.objenesis.instantiator.sun.SunReflectionFactorySerializationInstantiator; import static org.objenesis.strategy.PlatformDescription.*; /** * 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(HOTSPOT) || PlatformDescription.isThisJVM(OPENJDK)) { // Java 7 GAE was under a security manager so we use a degraded system if(isGoogleAppEngine() && PlatformDescription.SPECIFICATION_VERSION.equals("1.7")) { return new ObjectInputStreamInstantiator<>(type); } return new SunReflectionFactorySerializationInstantiator<>(type); } else if(JVM_NAME.startsWith(DALVIK)) { if(PlatformDescription.isAndroidOpenJDK()) { return new ObjectStreamClassInstantiator<>(type); } return new AndroidSerializationInstantiator<>(type); } else if(JVM_NAME.startsWith(GNU)) { return new GCJSerializationInstantiator<>(type); } else if(JVM_NAME.startsWith(PERC)) { return new PercSerializationInstantiator<>(type); } return new SunReflectionFactorySerializationInstantiator<>(type); } } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/SingleInstantiatorStrategy.java000066400000000000000000000044301336222440400316760ustar00rootroot00000000000000/* * Copyright 2006-2018 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.ObjenesisException; import org.objenesis.instantiator.ObjectInstantiator; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; /** * Strategy returning only one instantiator type. Useful if you know on which JVM Objenesis * will be used and want to specify it explicitly. * * @author Henri Tremblay */ public class SingleInstantiatorStrategy implements InstantiatorStrategy { private Constructor constructor; /** * Create a strategy that will return always the same instantiator type. We assume this instantiator * has one constructor taking the class to instantiate in parameter. * * @param the type we want to instantiate * @param instantiator the instantiator type */ public > SingleInstantiatorStrategy(Class instantiator) { try { constructor = instantiator.getConstructor(Class.class); } catch(NoSuchMethodException e) { throw new ObjenesisException(e); } } /** * Return an instantiator for the wanted type and of the one and only type of instantiator returned by this * class. * * @param the type we want to instantiate * @param type Class to instantiate * @return The ObjectInstantiator for the class */ @SuppressWarnings("unchecked") public ObjectInstantiator newInstantiatorOf(Class type) { try { return (ObjectInstantiator) constructor.newInstance(type); } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new ObjenesisException(e); } } } objenesis-3.0.1/main/src/main/java/org/objenesis/strategy/StdInstantiatorStrategy.java000066400000000000000000000074531336222440400312170ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android.Android10Instantiator; import org.objenesis.instantiator.android.Android17Instantiator; import org.objenesis.instantiator.android.Android18Instantiator; import org.objenesis.instantiator.basic.AccessibleInstantiator; import org.objenesis.instantiator.basic.ObjectInputStreamInstantiator; import org.objenesis.instantiator.gcj.GCJInstantiator; import org.objenesis.instantiator.perc.PercInstantiator; import org.objenesis.instantiator.sun.SunReflectionFactoryInstantiator; import org.objenesis.instantiator.sun.UnsafeFactoryInstantiator; import java.io.Serializable; import static org.objenesis.strategy.PlatformDescription.*; /** * 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(PlatformDescription.isThisJVM(HOTSPOT) || PlatformDescription.isThisJVM(OPENJDK)) { // Java 7 GAE was under a security manager so we use a degraded system if(PlatformDescription.isGoogleAppEngine() && PlatformDescription.SPECIFICATION_VERSION.equals("1.7")) { if(Serializable.class.isAssignableFrom(type)) { return new ObjectInputStreamInstantiator<>(type); } return new AccessibleInstantiator<>(type); } // The UnsafeFactoryInstantiator would also work. But according to benchmarks, it is 2.5 // times slower. So I prefer to use this one return new SunReflectionFactoryInstantiator<>(type); } else if(PlatformDescription.isThisJVM(DALVIK)) { if(PlatformDescription.isAndroidOpenJDK()) { // Starting at Android N which is based on OpenJDK return new UnsafeFactoryInstantiator<>(type); } if(ANDROID_VERSION <= 10) { // Android 2.3 Gingerbread and lower return new Android10Instantiator<>(type); } if(ANDROID_VERSION <= 17) { // Android 3.0 Honeycomb to 4.2 Jelly Bean return new Android17Instantiator<>(type); } // Android 4.3 until Android N return new Android18Instantiator<>(type); } else if(PlatformDescription.isThisJVM(GNU)) { return new GCJInstantiator<>(type); } else if(PlatformDescription.isThisJVM(PERC)) { return new PercInstantiator<>(type); } // Fallback instantiator, should work with most modern JVM return new UnsafeFactoryInstantiator<>(type); } } objenesis-3.0.1/main/src/test/000077500000000000000000000000001336222440400161665ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/000077500000000000000000000000001336222440400171075ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/android/000077500000000000000000000000001336222440400205275ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/android/os/000077500000000000000000000000001336222440400211505ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/android/os/Build.java000066400000000000000000000015611336222440400230550ustar00rootroot00000000000000/* * Copyright 2006-2018 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 android.os; /** * Mimics the real Android class. Used for testing * * @author Henri Tremblay */ public class Build { public static class VERSION { public static final int SDK_INT = 42; public static final String SDK = "42"; } } objenesis-3.0.1/main/src/test/java/org/000077500000000000000000000000001336222440400176765ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/000077500000000000000000000000001336222440400216575ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/ClassReader.java000066400000000000000000000255001336222440400247140ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util.ClassUtils; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import static org.junit.Assert.*; import static org.objenesis.instantiator.util.ClassDefinitionUtils.*; /** * @author Henri Tremblay */ public class ClassReader { private final byte[] buffer = new byte[256]; private Object[] constant_pool; public static void main(String[] args) throws IOException { if(args.length != 1) { System.out.println("Usage: ClassReader (path_to_the_class_file|class:complete_class_name)"); } ClassReader reader = new ClassReader(); reader.readClass(args[0]); } static class CONSTANT_Utf8_info { // int length; u2 is read by readUTF String bytes; CONSTANT_Utf8_info(DataInputStream in) throws IOException { bytes = in.readUTF(); } @Override public String toString() { return "CONSTANT_Utf8_info{" + "bytes='" + bytes + '\'' + '}'; } } static class CONSTANT_Methodref_info { int class_index; // u2 int name_and_type_index; // u2 CONSTANT_Methodref_info(DataInputStream in) throws IOException { class_index = in.readUnsignedShort(); name_and_type_index = in.readUnsignedShort(); } @Override public String toString() { return "CONSTANT_Methodref_info{" + "class_index=" + class_index + ", name_and_type_index=" + name_and_type_index + '}'; } } static class CONSTANT_Class_info { int name_index; // u2 public CONSTANT_Class_info(DataInputStream in) throws IOException{ name_index = in.readUnsignedShort(); } @Override public String toString() { return "CONSTANT_Class_info{" + "name_index=" + name_index + '}'; } } static class CONSTANT_NameAndType_info { int name_index; // u2 int descriptor_index; // u2 public CONSTANT_NameAndType_info(DataInputStream in) throws IOException{ name_index = in.readUnsignedShort(); descriptor_index = in.readUnsignedShort(); } @Override public String toString() { return "CONSTANT_NameAndType_info{" + "name_index=" + name_index + ", descriptor_index=" + descriptor_index + '}'; } } class method_info { int access_flags; // u2 int name_index; int descriptor_index; int attributes_count; attribute_info[] attributes; public method_info(DataInputStream in) throws IOException{ access_flags = in.readUnsignedShort(); name_index = in.readUnsignedShort(); descriptor_index = in.readUnsignedShort(); attributes_count = in.readUnsignedShort(); attributes = new attribute_info[attributes_count]; for (int i = 0; i < attributes_count; i++) { attributes[i] = new attribute_info(in); } } @Override public String toString() { return "method_info{" + "access_flags=" + access_flags + ", name_index=" + name_index + ", descriptor_index=" + descriptor_index + ", attributes_count=" + attributes_count + '}'; } } class attribute_info { int attribute_name_index; // u2 int attribute_length; // u4 Object info; public attribute_info(DataInputStream in) throws IOException{ attribute_name_index = in.readUnsignedShort(); attribute_length = in.readInt(); String attribute_name = ((CONSTANT_Utf8_info) constant_pool[attribute_name_index]).bytes; System.out.println(this + " " + attribute_name); if("Code".equals(attribute_name)) { info = new Code_attribute(in); } else if("SourceFile".equals(attribute_name)) { assertEquals(2, attribute_length); // always 2 info = new SourceFile_attribute(in); } else if("LineNumberTable".equals(attribute_name)) { // I don't care about that (only used for debugging) so I will skip System.out.println("Attribute LineNumberTable skipped"); in.read(buffer, 0, attribute_length); } else if("LocalVariableTable".equals(attribute_name)) { // I don't care about that (only used for debugging) so I will skip System.out.println("Attribute LocalVariableTable skipped"); in.read(buffer, 0, attribute_length); } else { fail("Unknown attribute: " + attribute_name); } System.out.println("\t" + info); } @Override public String toString() { return "attribute_info{" + "attribute_name_index=" + attribute_name_index + ", attribute_length=" + attribute_length + '}'; } } class Code_attribute { int max_stack; // u2 int max_locals; // u2 int code_length; // u4 byte[] code; // length of code_length int exception_table_length; // u2 if will be 0, so we will skip the exception_table int attributes_count; // u2 attribute_info[] attributes; Code_attribute(DataInputStream in) throws IOException { max_stack = in.readUnsignedShort(); max_locals = in.readUnsignedShort(); code_length = in.readInt(); code = new byte[code_length]; in.read(code); exception_table_length = in.readUnsignedShort(); attributes_count = in.readUnsignedShort(); attributes = new attribute_info[attributes_count]; for (int i = 0; i < attributes_count; i++) { attributes[i] = new attribute_info(in); } } @Override public String toString() { return "Code_attribute{" + "max_stack=" + max_stack + ", max_locals=" + max_locals + ", code_length=" + code_length + ", code=" + Arrays.toString(code) + ", exception_table_length=" + exception_table_length + ", attributes_count=" + attributes_count + '}'; } } static class SourceFile_attribute { int sourcefile_index; SourceFile_attribute(DataInputStream in) throws IOException { sourcefile_index = in.readUnsignedShort(); } @Override public String toString() { return "SourceFile_attribute{" + "sourcefile_index=" + sourcefile_index + '}'; } } public void readClass(String classPath) throws IOException { InputStream iin; if(classPath.startsWith("classpath:")) { String className = classPath.substring("classpath:".length()); String resourceName = ClassUtils.classNameToResource(className); iin = getClass().getClassLoader().getResourceAsStream(resourceName); } else { iin = new FileInputStream(classPath); } DataInputStream in = new DataInputStream(iin); // magic number in.read(buffer, 0, MAGIC.length); assertArrayEquals(MAGIC); // version in.read(buffer, 0, VERSION.length); assertArrayEquals(VERSION); // constant_pool_count int constant_pool_count = in.readUnsignedShort(); System.out.println("Constant pool count: " + constant_pool_count); // indexed from 1 (0 will be unused) to constant_pool_count-1 constant_pool = new Object[constant_pool_count]; // constant pool for (int i = 1; i < constant_pool_count; i++) { System.out.print(i + ": "); int type = in.readUnsignedByte(); switch(type) { case CONSTANT_Utf8: constant_pool[i] = new CONSTANT_Utf8_info(in); break; case CONSTANT_Class: constant_pool[i] = new CONSTANT_Class_info(in); break; case CONSTANT_Methodref: constant_pool[i] = new CONSTANT_Methodref_info(in); break; case CONSTANT_NameAndType: constant_pool[i] = new CONSTANT_NameAndType_info(in); break; default: fail("Unknown type: " + type); } System.out.println(constant_pool[i]); } // access flags int access_flags = in.readUnsignedShort(); System.out.println("Access flags: " + access_flags); // see http://stackoverflow.com/questions/8949933/what-is-the-purpose-of-the-acc-super-access-flag-on-java-class-files // this class name int this_class = in.readUnsignedShort(); System.out.println("This class index: " + this_class); // super class name int super_class = in.readUnsignedShort(); System.out.println("This superclass index: " + super_class); // interfaces implemented count (we have none) int interfaces_count = in.readUnsignedShort(); System.out.println("Interfaces count: " + interfaces_count); for (int i = 0; i < interfaces_count; i++) { int index = in.readUnsignedShort(); System.out.println("Interface " + i + " index: " + index); } // fields count (we have none) int fields_count = in.readUnsignedShort(); System.out.println("Fields count: " + fields_count); assertEquals("Reading fields isn't yet supported", 0, fields_count); //methods count (we have one) int methods_count = in.readUnsignedShort(); System.out.println("Methods count: " + methods_count); for (int i = 0; i < methods_count; i++) { method_info methodInfo = new method_info(in); System.out.println("for " + methodInfo); } // reading final class attributes int attributes_count = in.readUnsignedShort(); System.out.println("Class attributes count: " + attributes_count); for (int i = 0; i < attributes_count ; i++) { attribute_info attributeInfo = new attribute_info(in); } in.close(); } private void assertArrayEquals(byte[] expected) { for (int i = 0; i < expected.length; i++) { if(expected[i] != buffer[i]) { fail("Expected was " + Arrays.toString(expected) + " but actual is " + Arrays.toString(buffer)); } } } } objenesis-3.0.1/main/src/test/java/org/objenesis/EmptyClass.java000066400000000000000000000015641336222440400246140ustar00rootroot00000000000000/* * Copyright 2006-2018 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.Date; /** * Just used for testing. To see the bytecode of a really simple class * * @author Henri Tremblay */ public class EmptyClass extends Date { public EmptyClass() { throw new RuntimeException(); } } objenesis-3.0.1/main/src/test/java/org/objenesis/EmptyClassBis.java000066400000000000000000000015721336222440400252510ustar00rootroot00000000000000/* * Copyright 2006-2018 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.Date; /** * Just used for testing. To see the bytecode of a really simple class * * @author Henri Tremblay */ public class EmptyClassBis extends Date { public EmptyClassBis() { throw new RuntimeException(); } } objenesis-3.0.1/main/src/test/java/org/objenesis/ExternalizableTest.java000066400000000000000000000031431336222440400263340ustar00rootroot00000000000000/* * Copyright 2006-2018 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.Externalizable; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; import org.junit.Test; import static org.junit.Assert.*; /** * This test makes sure issue #33 is not occurring. * * @author Henri Tremblay */ public class ExternalizableTest { public static class C { public int val = 33; protected C() {} } public static class B extends C implements Serializable { public B() { fail("B constructor shouldn't be called"); } } public static class A extends B implements Externalizable { public A() { fail("A constructor shouldn't be called"); } public void writeExternal(ObjectOutput out) { } public void readExternal(ObjectInput in) { } } @Test public void test() { A a = ObjenesisHelper.newSerializableInstance(A.class); // The constructor from C should have been called assertEquals(33, a.val); } } objenesis-3.0.1/main/src/test/java/org/objenesis/ObjenesisExceptionTest.java000066400000000000000000000033631336222440400271670ustar00rootroot00000000000000/* * Copyright 2006-2018 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 static org.junit.Assert.*; import org.junit.Test; /** * @author Henri Tremblay */ public class ObjenesisExceptionTest { @Test public final void testObjenesisExceptionString() { Exception e = new ObjenesisException("test"); assertEquals("test", e.getMessage()); } @Test 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()); assertNull(e.getMessage()); } @Test 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()); } } objenesis-3.0.1/main/src/test/java/org/objenesis/ObjenesisTest.java000066400000000000000000000053271336222440400253120ustar00rootroot00000000000000/* * Copyright 2006-2018 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.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.strategy.InstantiatorStrategy; import static org.junit.Assert.*; /** * @author Henri Tremblay */ public class ObjenesisTest { @Rule public ExpectedException expectedException = ExpectedException.none(); @Test public final void testObjenesis() { Objenesis o = new ObjenesisStd(); assertEquals( "org.objenesis.ObjenesisStd using org.objenesis.strategy.StdInstantiatorStrategy with caching", o.toString()); } @Test 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()); } @Test public final void testNewInstance() { Objenesis o = new ObjenesisStd(); assertEquals(getClass(), o.newInstance(getClass()).getClass()); } @Test 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); } @Test public final void testGetInstantiatorOf_primitive() { Objenesis o = new ObjenesisStd(); expectedException.expect(IllegalArgumentException.class); o.getInstantiatorOf(long.class); } @Test 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; } } objenesis-3.0.1/main/src/test/java/org/objenesis/SerializingInstantiatorTest.java000066400000000000000000000022301336222440400302370ustar00rootroot00000000000000/* * Copyright 2006-2018 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 static org.junit.Assert.*; import java.io.NotSerializableException; import org.junit.Test; /** * @author Henri Tremblay * @author Leonardo Mesquita */ public class SerializingInstantiatorTest { @Test 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); } } } objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/000077500000000000000000000000001336222440400243765ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/basic/000077500000000000000000000000001336222440400254575ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/basic/ProxyingInstantiatorTest.java000066400000000000000000000023111336222440400333760ustar00rootroot00000000000000/* * Copyright 2006-2018 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.junit.Ignore; import org.junit.Test; import org.objenesis.EmptyClass; import org.objenesis.instantiator.ObjectInstantiator; import static org.junit.Assert.*; /** * @author Henri Tremblay */ @Ignore("Because it doesn't work without -Xverify:none") public class ProxyingInstantiatorTest { @Test public void testNewInstance() { ObjectInstantiator inst = new ProxyingInstantiator<>(EmptyClass.class); EmptyClass c = inst.newInstance(); assertEquals("EmptyClass$$$Objenesis", c.getClass().getSimpleName()); } } objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/sun/000077500000000000000000000000001336222440400252035ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/sun/MagicInstantiatorTest.java000066400000000000000000000035511336222440400323320ustar00rootroot00000000000000/* * Copyright 2006-2018 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.junit.Before; import org.junit.Test; import org.objenesis.EmptyClass; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.strategy.PlatformDescription; import static org.junit.Assert.*; import static org.junit.Assume.*; /** * @author Henri Tremblay */ public class MagicInstantiatorTest { @Before public void before() { // I know it works on Hotspot and OpenJDK. Before JDK 9. Not sure on others assumeTrue((PlatformDescription.isThisJVM(PlatformDescription.HOTSPOT) || PlatformDescription.isThisJVM(PlatformDescription.OPENJDK)) && !PlatformDescription.isAfterJigsaw() ); } @Test public void testNewInstance() { ObjectInstantiator o1 = new MagicInstantiator<>(EmptyClass.class); assertEquals(EmptyClass.class, o1.newInstance().getClass()); ObjectInstantiator o2 = new MagicInstantiator<>(EmptyClass.class); assertEquals(EmptyClass.class, o2.newInstance().getClass()); } @Test public void testInternalInstantiator() { ObjectInstantiator o1 = new MagicInstantiator<>(EmptyClass.class).getInstantiator(); assertEquals(EmptyClass.class, o1.newInstance().getClass()); } } objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/util/000077500000000000000000000000001336222440400253535ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/util/ClassDefinitionUtilsTest.java000066400000000000000000000022361336222440400331600ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import org.junit.Test; import org.objenesis.Objenesis; import static org.junit.Assert.*; /** * @author Henri Tremblay */ public class ClassDefinitionUtilsTest { private final String className = "org.objenesis.EmptyClassBis"; @Test public void testDefineClass() throws Exception { byte[] b = ClassDefinitionUtils.readClass(className); Class c = ClassDefinitionUtils.defineClass(className, b, Objenesis.class, getClass().getClassLoader()); assertEquals(c.getName(), className); } } objenesis-3.0.1/main/src/test/java/org/objenesis/instantiator/util/ClassUtilsTest.java000066400000000000000000000045371336222440400311550ustar00rootroot00000000000000/* * Copyright 2006-2018 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.util; import org.junit.Test; import org.objenesis.ObjenesisException; import java.util.ArrayList; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** * @author Henri Tremblay */ public class ClassUtilsTest { private final String className = "org.objenesis.EmptyClassBis"; @Test public void testClassNameToInternalClassName() { String actual = ClassUtils.classNameToInternalClassName(className); assertEquals("org/objenesis/EmptyClassBis", actual); } @Test public void testClassNameToResource() { String actual = ClassUtils.classNameToResource(className); assertEquals("org/objenesis/EmptyClassBis.class", actual); } @Test public void testGetExistingClass_existing() { Class actual = ClassUtils.getExistingClass(getClass().getClassLoader(), getClass().getName()); assertSame(actual, getClass()); } @Test public void testGetExistingClass_notExisting() { Class actual = ClassUtils.getExistingClass(getClass().getClassLoader(), getClass().getName() + "$$$1"); assertNull(actual); } @Test public void testNewInstance_noArgsConstructorPresent() { ArrayList i = ClassUtils.newInstance(ArrayList.class); assertTrue(i.isEmpty()); } @Test public void testNewInstance_noArgsConstructorAbsent() { try { ClassUtils.newInstance(Integer.class); fail("No arg constructor. It should fail"); } catch(ObjenesisException e) { assertEquals(InstantiationException.class, e.getCause().getClass()); } } } objenesis-3.0.1/main/src/test/java/org/objenesis/strategy/000077500000000000000000000000001336222440400235215ustar00rootroot00000000000000objenesis-3.0.1/main/src/test/java/org/objenesis/strategy/PlatformDescriptionTest.java000066400000000000000000000033251336222440400312170ustar00rootroot00000000000000/* * Copyright 2006-2018 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.lang.reflect.Method; import org.junit.Test; import static org.junit.Assert.*; /** * Currently the test just check nothing is crashing. A more complex test should play with class * loading an properties * * @author Henri Tremblay */ public class PlatformDescriptionTest { @Test public void isJvmName() { PlatformDescription.isThisJVM(PlatformDescription.HOTSPOT); } @Test public void test() { if(!PlatformDescription.isThisJVM(PlatformDescription.DALVIK)) { assertEquals(0, PlatformDescription.ANDROID_VERSION); } } @Test public void testAndroidVersion() throws Exception { Method m = PlatformDescription.class.getDeclaredMethod("getAndroidVersion0"); m.setAccessible(true); int actual = (Integer) m.invoke(null); assertEquals(42, actual); } @Test public void isAfterJigsaw() { PlatformDescription.isAfterJigsaw(); // just make sure it doesn't crash } @Test public void isAfterJava11() { PlatformDescription.isAfterJava11(); // just make sure it doesn't crash } } objenesis-3.0.1/objenesis-formatting.xml000066400000000000000000000743061336222440400203610ustar00rootroot00000000000000 objenesis-3.0.1/pom.xml000066400000000000000000000414311336222440400150140ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 pom Objenesis parent project A library for instantiating Java objects http://objenesis.org 2006 3.2.1 main tck Apache 2 http://www.apache.org/licenses/LICENSE-2.0.txt repo Joe Walnes, Henri Tremblay, Leonardo Mesquita https://github.com/easymock/objenesis scm:git:git@github.com:easymock/objenesis.git scm:git:https://github.com/easymock/objenesis.git 3.0.1 joe Joe Walnes -5 henri Henri Tremblay -5 leonardo Leonardo Mesquita -5 1.8 UTF-8 3.1.6 junit junit 4.12 junit junit test maven-compiler-plugin ${java.version} ${java.version} maven-jar-plugin true false true true maven-release-plugin true @{project.version} false false release,full,all true maven-site-plugin false ${project.basedir}/website com.mycila license-maven-plugin false true org.apache.maven.wagon wagon-ssh-external 2.10 maven-assembly-plugin 3.1.0 maven-compiler-plugin 3.8.0 maven-jar-plugin 3.1.0 maven-surefire-plugin 2.22.0 maven-clean-plugin 3.1.0 maven-deploy-plugin 3.0.0-M1 maven-gpg-plugin 1.6 sign-artifacts verify sign maven-install-plugin 3.0.0-M1 maven-release-plugin 2.5.3 maven-resources-plugin 3.1.0 maven-shade-plugin 3.2.0 maven-site-plugin 3.7.1 maven-source-plugin 3.0.1 maven-javadoc-plugin 3.0.1 maven-war-plugin 3.2.2 org.apache.felix maven-bundle-plugin 4.0.0 com.keyboardsamurais.maven maven-timestamp-plugin 1.0 year create year yyyy com.mycila license-maven-plugin 3.0
${project.basedir}/../header.txt
true SLASHSTAR_STYLE .gitignore target/** dependency-reduced-pom.xml eclipse_config/** website/** **/*.bat project.properties lint.xml gen/** bin/** **/*.txt **/*.launch **/*.md website/site/resources/CNAME website/site/resources/.nojekyll ${project.inceptionYear} ${year}
maven-remote-resources-plugin 1.5 process org.apache:apache-jar-resource-bundle:1.3 org.codehaus.mojo exec-maven-plugin 1.6.0 org.codehaus.mojo versions-maven-plugin 2.7 com.github.spotbugs spotbugs-maven-plugin ${spotbugs-maven-plugin.version} true Naming org.eclipse.m2e lifecycle-mapping 1.0.0 com.keyboardsamurais.maven maven-timestamp-plugin [1.0,) create maven-remote-resources-plugin [1.0,) process com.github.spotbugs spotbugs-maven-plugin [2.5.5,) spotbugs
maven-project-info-reports-plugin 3.0.0 com.github.spotbugs spotbugs-maven-plugin ${spotbugs-maven-plugin.version} maven-pmd-plugin 3.10.0 1.6 bintray JFrog Bintray https://api.bintray.com/maven/easymock/maven/objenesis/;publish=1 full maven-source-plugin attach-sources jar maven-javadoc-plugin attach-javadocs jar com.github.spotbugs spotbugs-maven-plugin spotbugs spotbugs com.mycila license-maven-plugin check check website website android tck-android benchmark benchmark gae gae release maven-gpg-plugin all benchmark tck-android gae website
objenesis-3.0.1/settings-example.xml000066400000000000000000000006361336222440400175140ustar00rootroot00000000000000 sonatype-nexus-snapshots myusername mypassword sonatype-nexus-staging myusername mypassword objenesis-3.0.1/tck-android/000077500000000000000000000000001336222440400156735ustar00rootroot00000000000000objenesis-3.0.1/tck-android/.gitignore000066400000000000000000000001751336222440400176660ustar00rootroot00000000000000bin/ gen/ target/ .classpath .project org.eclipse.m2e.core.prefs org.eclipse.core.resources.prefs org.eclipse.pde.core.prefs objenesis-3.0.1/tck-android/.settings/000077500000000000000000000000001336222440400176115ustar00rootroot00000000000000objenesis-3.0.1/tck-android/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000572231336222440400246040ustar00rootroot00000000000000eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.5 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_annotation=0 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_method_declaration=0 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_resources_in_try=80 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.alignment_for_union_type_in_multicatch=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_import_groups=1 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_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_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_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=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.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 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.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 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_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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_try=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_semicolon_in_try_resources=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_try=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_try=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_parenthesized_expression_in_throw=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_semicolon_in_try_resources=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.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true 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.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 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_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true objenesis-3.0.1/tck-android/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000052431336222440400242640ustar00rootroot00000000000000eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Objenesis formatter_settings_version=12 sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=true sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true objenesis-3.0.1/tck-android/lint.xml000066400000000000000000000000651336222440400173640ustar00rootroot00000000000000 objenesis-3.0.1/tck-android/pom.xml000066400000000000000000000120211336222440400172040ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 objenesis-tck-android Objenesis Android TCK Objenesis' TCK built for Android devices apk ${env.ANDROID_HOME} org.objenesis objenesis ${project.version} provided ${project.groupId} objenesis-tck ${project.version} com.google.android android 4.1.1.4 provided com.google.android android-test 4.1.1.4 provided junit junit org.hamcrest hamcrest-core com.simpligility.maven.plugins android-maven-plugin 4.5.0 true false org.objenesis.tck.android android.test.InstrumentationTestRunner com.keyboardsamurais.maven maven-timestamp-plugin com.mycila license-maven-plugin maven-remote-resources-plugin com.simpligility.maven.plugins android-maven-plugin 27 --min-sdk-version=26 true org.codehaus.mojo exec-maven-plugin false execute integration-test exec ${android.home}/platform-tools/adb shell am instrument -w org.objenesis.tck.android/.TckInstrumentation intellij-specific ${project.groupId} objenesis ${project.version} objenesis-3.0.1/tck-android/project.properties000066400000000000000000000000441336222440400214550ustar00rootroot00000000000000# Project target. target=android-26 objenesis-3.0.1/tck-android/src/000077500000000000000000000000001336222440400164625ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/000077500000000000000000000000001336222440400174065ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/AndroidManifest.xml000066400000000000000000000030121336222440400231730ustar00rootroot00000000000000 objenesis-3.0.1/tck-android/src/main/java/000077500000000000000000000000001336222440400203275ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/java/org/000077500000000000000000000000001336222440400211165ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/java/org/objenesis/000077500000000000000000000000001336222440400230775ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/java/org/objenesis/tck/000077500000000000000000000000001336222440400236605ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/java/org/objenesis/tck/android/000077500000000000000000000000001336222440400253005ustar00rootroot00000000000000objenesis-3.0.1/tck-android/src/main/java/org/objenesis/tck/android/ObjenesisTest.java000066400000000000000000000045341336222440400307320ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android; import java.io.ByteArrayOutputStream; import java.io.PrintStream; import org.objenesis.Objenesis; import org.objenesis.ObjenesisSerializer; import org.objenesis.ObjenesisStd; import org.objenesis.tck.Candidate; import org.objenesis.tck.Reporter; import org.objenesis.tck.TCK; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; /** * Test case running the entire tck on android. * * @author Henri Tremblay */ public class ObjenesisTest extends AndroidTestCase { public static class JUnitReporter implements Reporter { private Candidate currentCandidate; @Override public void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer) { } @Override public void startTest(Candidate candidate) { currentCandidate = candidate; } @Override public void exception(Candidate.CandidateType type, Exception exception) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try (PrintStream out = new PrintStream(buffer)) { out.println("Exception when instantiating " + currentCandidate + " for " + type + ": "); exception.printStackTrace(out); fail(buffer.toString()); } } @Override public void result(Candidate.CandidateType type, boolean worked) { assertTrue("Instantiating " + currentCandidate + " for " + type + " failed", worked); } @Override public void endTests() { } } @SmallTest public void testObjenesis() throws Exception { TCK tck = new TCK(new ObjenesisStd(), new ObjenesisSerializer(), new JUnitReporter()); tck.runTests(); } } objenesis-3.0.1/tck-android/src/main/java/org/objenesis/tck/android/TckInstrumentation.java000066400000000000000000000033141336222440400320110ustar00rootroot00000000000000/* * Copyright 2006-2018 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.android; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import org.objenesis.tck.Main; import org.objenesis.tck.TextReporter; import android.app.Activity; import android.app.Instrumentation; import android.os.Bundle; /** * Wraps the Objenesis TCK so that it can be invoked on Android as an {@link Instrumentation}. * * @author Ian Parkinson (Google Inc.) */ public class TckInstrumentation extends Instrumentation { @Override public void onCreate(Bundle arguments) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(outputStream); System.setOut(printStream); System.setErr(printStream); launch(); Bundle bundle = new Bundle(); String fromStdout = outputStream.toString(); bundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, fromStdout); finish(Activity.RESULT_OK, bundle); } private void launch() { TextReporter reporter = new TextReporter(System.out, System.err); Main.run(reporter); } } objenesis-3.0.1/tck/000077500000000000000000000000001336222440400142555ustar00rootroot00000000000000objenesis-3.0.1/tck/.settings/000077500000000000000000000000001336222440400161735ustar00rootroot00000000000000objenesis-3.0.1/tck/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000575201336222440400231660ustar00rootroot00000000000000eclipse.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.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.5 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_annotation=0 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_method_declaration=0 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_resources_in_try=80 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.alignment_for_union_type_in_multicatch=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_import_groups=1 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.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=true org.eclipse.jdt.core.formatter.comment.format_block_comments=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_javadoc_comments=true org.eclipse.jdt.core.formatter.comment.format_line_comments=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.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 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.disabling_tag=@formatter\:off org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 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_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not 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_try=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_semicolon_in_try_resources=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_try=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_try=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_parenthesized_expression_in_throw=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_semicolon_in_try_resources=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.join_lines_in_comments=true org.eclipse.jdt.core.formatter.join_wrapped_lines=true 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.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 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_on_off_tags=false org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true objenesis-3.0.1/tck/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000057301336222440400226470ustar00rootroot00000000000000eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true formatter_profile=_Objenesis formatter_settings_version=12 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= sp_cleanup.add_default_serial_version_id=true sp_cleanup.add_generated_serial_version_id=false sp_cleanup.add_missing_annotations=true sp_cleanup.add_missing_deprecated_annotations=true sp_cleanup.add_missing_methods=false sp_cleanup.add_missing_nls_tags=false sp_cleanup.add_missing_override_annotations=true sp_cleanup.add_missing_override_annotations_interface_methods=true sp_cleanup.add_serial_version_id=false sp_cleanup.always_use_blocks=true sp_cleanup.always_use_parentheses_in_expressions=false sp_cleanup.always_use_this_for_non_static_field_access=false sp_cleanup.always_use_this_for_non_static_method_access=false sp_cleanup.convert_to_enhanced_for_loop=false sp_cleanup.correct_indentation=false sp_cleanup.format_source_code=true sp_cleanup.format_source_code_changes_only=true sp_cleanup.make_local_variable_final=false sp_cleanup.make_parameters_final=false sp_cleanup.make_private_fields_final=true sp_cleanup.make_type_abstract_if_missing_method=false sp_cleanup.make_variable_declarations_final=false sp_cleanup.never_use_blocks=false sp_cleanup.never_use_parentheses_in_expressions=true sp_cleanup.on_save_use_additional_actions=true sp_cleanup.organize_imports=true sp_cleanup.qualify_static_field_accesses_with_declaring_class=false sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true sp_cleanup.qualify_static_member_accesses_with_declaring_class=false sp_cleanup.qualify_static_method_accesses_with_declaring_class=false sp_cleanup.remove_private_constructors=true sp_cleanup.remove_trailing_whitespaces=false sp_cleanup.remove_trailing_whitespaces_all=true sp_cleanup.remove_trailing_whitespaces_ignore_empty=false sp_cleanup.remove_unnecessary_casts=true sp_cleanup.remove_unnecessary_nls_tags=false sp_cleanup.remove_unused_imports=false sp_cleanup.remove_unused_local_variables=false sp_cleanup.remove_unused_private_fields=true sp_cleanup.remove_unused_private_members=false sp_cleanup.remove_unused_private_methods=true sp_cleanup.remove_unused_private_types=true sp_cleanup.sort_members=false sp_cleanup.sort_members_all=false sp_cleanup.use_blocks=false sp_cleanup.use_blocks_only_for_return_and_throw=false sp_cleanup.use_parentheses_in_expressions=false sp_cleanup.use_this_for_non_static_field_access=false sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true sp_cleanup.use_this_for_non_static_method_access=false sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true objenesis-3.0.1/tck/pom.xml000066400000000000000000000130331336222440400155720ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 objenesis-tck Objenesis TCK Objenesis' TCK http://objenesis.org 4.12.0 org.objenesis objenesis ${project.version} org.ops4j.pax.exam pax-exam-junit4 ${paxexam.version} test org.osgi org.osgi.core org.ops4j.pax.exam pax-exam-container-native ${paxexam.version} test org.ops4j.pax.exam pax-exam-link-mvn ${paxexam.version} test org.apache.felix org.apache.felix.framework 6.0.1 test ch.qos.logback logback-classic 1.2.3 test com.keyboardsamurais.maven maven-timestamp-plugin com.mycila license-maven-plugin maven-remote-resources-plugin maven-jar-plugin org.objenesis.tck.Main org.objenesis.tck maven-shade-plugin false package shade maven-javadoc-plugin jvm-test maven-surefire-plugin specific-jvm test test ${my.jvm} full org.codehaus.mojo exec-maven-plugin false java -jar ${project.build.directory}/${project.build.finalName}.jar test-release integration-test exec objenesis-3.0.1/tck/src/000077500000000000000000000000001336222440400150445ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/000077500000000000000000000000001336222440400157705ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/000077500000000000000000000000001336222440400167115ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/000077500000000000000000000000001336222440400175005ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/000077500000000000000000000000001336222440400214615ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/000077500000000000000000000000001336222440400222425ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/AbstractLoader.java000066400000000000000000000104341336222440400260010ustar00rootroot00000000000000/* * Copyright 2006-2018 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; /** * Class loading a property file and delegating the treatment of each line to a concrete implementations. * * @author Henri Tremblay */ public abstract class AbstractLoader { private final ClassLoader classloader; private final ErrorHandler errorHandler; /** * Handler for reporting errors from the AbstractLoader. */ public 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 classloader ClassLoader from which candidates classes are loaded * @param errorHandler Handler called in case of error */ public AbstractLoader(ClassLoader classloader, ErrorHandler errorHandler) { this.classloader = classloader; this.errorHandler = errorHandler; } /** * @param inputStream Stream containing the properties * @param type Type of the candidate loaded from the stream * @throws IOException If something goes wrong while reading the stream */ public void loadFrom(InputStream inputStream, final Candidate.CandidateType type) 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 concrete implementations. Properties properties = new Properties() { private static final long serialVersionUID = 1L; @Override public Object put(Object key, Object value) { handlePropertyEntry((String) key, (String) value, type); return null; } }; properties.load(inputStream); } /** * Load a candidate property file * * @param resource File name * @param type Type of the candidate loaded from the stream * @throws IOException If there's problem reading the file */ public void loadFromResource(String resource, Candidate.CandidateType type) throws IOException { InputStream candidatesConfig = classloader.getResourceAsStream(resource); if(candidatesConfig == null) { throw new IOException("Resource '" + resource + "' not found"); } try { loadFrom(candidatesConfig, type); } finally { candidatesConfig.close(); } } private void handlePropertyEntry(String key, String value, Candidate.CandidateType type) { try { Class candidate = Class.forName(key, true, classloader); handlePropertyEntry(candidate, value, type); } catch(ClassNotFoundException e) { errorHandler.classNotFound(key); } } /** * Will receive one class and its description pairs from the file * * @param clazz class on the line * @param description description of the class * @param type type of the candidate */ protected abstract void handlePropertyEntry(Class clazz, String description, Candidate.CandidateType type); } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/Candidate.java000066400000000000000000000037331336222440400247670ustar00rootroot00000000000000/* * Copyright 2006-2018 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.Arrays; import java.util.EnumSet; /** * Represents a candidate for instantiation * * @author Henri Tremblay */ public class Candidate implements Comparable { public enum CandidateType { STANDARD, SERIALIZATION, } private final Class clazz; private final String description; private final EnumSet types; public Candidate(Class clazz, String description, CandidateType... types) { this.clazz = clazz; this.description = description; this.types = EnumSet.copyOf(Arrays.asList(types)); } public Class getClazz() { return clazz; } public String getDescription() { return description; } public EnumSet getTypes() { return types; } @Override public boolean equals(Object o) { if(this == o) { return true; } if(o == null || getClass() != o.getClass()) { return false; } Candidate candidate = (Candidate) o; return clazz.equals(candidate.clazz); } @Override public int hashCode() { return clazz.hashCode(); } @Override public int compareTo(Candidate o) { return description.compareTo(o.description); } @Override public String toString() { return clazz.getName() + "[" + description + "]"; } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/CandidateLoader.java000066400000000000000000000025501336222440400261120ustar00rootroot00000000000000/* * Copyright 2006-2018 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; /** * 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 */ class CandidateLoader extends AbstractLoader { private final TCK tck; /** * @param tck TCK that will use the candidates * @param errorHandler Handler called in case of error */ public CandidateLoader(TCK tck, AbstractLoader.ErrorHandler errorHandler) { super(tck.getClass().getClassLoader(), errorHandler); this.tck = tck; } protected void handlePropertyEntry(Class clazz, String description, Candidate.CandidateType type) { tck.registerCandidate(clazz, description, type); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/Main.java000066400000000000000000000030251336222440400237710ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.objenesis.ObjenesisSerializer; import org.objenesis.ObjenesisStd; /** * Command line launcher for Technology Compatibility Kit (TCK). * * @author Joe Walnes * @author Henri Tremblay * @see TCK */ public class Main { /** * Main class of the TCK. Can also be called as a normal method from an application server. * * @param args No parameters are required */ public static void main(String[] args) { TextReporter reporter = new TextReporter(System.out, System.err); run(reporter); if(reporter.hasErrors()) { System.exit(1); } } /** * Run the full test suite using standard Objenesis instances * * @param reporter result are recorded in the reporter */ public static void run(Reporter reporter) { TCK tck = new TCK(new ObjenesisStd(), new ObjenesisSerializer(), reporter); tck.runTests(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/Reporter.java000066400000000000000000000043641336222440400247160ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.objenesis.Objenesis; /** * Reports results from the TCK back to the user. *

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

 * startTests(startTest(result | exception)) * endTests
 * 
* * @author Joe Walnes * @author Henri Tremblay * @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 objenesisStandard Standard Objenesis instance used * @param objenesisSerializer Serialization Objenesis instance used */ void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer); /** * Report that a test between a candidate and an objenesis instance is about to start. * * @param candidate Starting to test this candidate. */ void startTest(Candidate candidate); /** * Report details about what happened when performing an instantiation test or a serialization feature test. * * @param type type of test * @param worked Whether the test was successful or not */ void result(Candidate.CandidateType type, boolean worked); /** * Report that something bad happened during the test. * * @param type type of test * @param exception Exception thrown */ void exception(Candidate.CandidateType type, Exception exception); /** * Report that all tests have finished. Nothing will be called after this method. */ void endTests(); } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/TCK.java000066400000000000000000000136331336222440400235340ustar00rootroot00000000000000/* * Copyright 2006-2018 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.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.objenesis.Objenesis; import org.objenesis.strategy.PlatformDescription; import org.objenesis.tck.features.Feature; /** * Technology Compatibility Kit (TCK) for {@link Objenesis}s. *

* This TCK tests Objenesis implementations against a set of candidate classes (class it attempts to instantiate), * reporting the results to a {@link Reporter}. * *

Example usage

* *
 * TextReporter reporter = new TextReporter(System.out, System.err);
 * TCK tck = new TCK(new ObjenesisStd(), new ObjenesisSerializer(), reporter);
 * tck.runTests(reporter);
 * reporter.printResults();
 * 
* * @author Joe Walnes * @author Henri Tremblay * @see org.objenesis.instantiator.ObjectInstantiator * @see Reporter * @see Main */ public class TCK { private final Objenesis objenesisStandard; private final Objenesis objenesisSerializer; private final Reporter reporter; private final List candidates = new ArrayList<>(); /** * @param objenesisStandard Objenesis instance used to instantiate classes the standard way (no constructor called) * @param objenesisSerializer Objenesis instance used to instantiate classes in a serialization compliant way (first not serializable constructor called) * @param reporter Where to report the results of the tests to */ public TCK(Objenesis objenesisStandard, Objenesis objenesisSerializer, Reporter reporter) { this.objenesisStandard = objenesisStandard; this.objenesisSerializer = objenesisSerializer; this.reporter = reporter; try { loadCandidates(); } catch(IOException e) { throw new RuntimeException(e); } Collections.sort(candidates); } protected void loadCandidates() throws IOException { CandidateLoader candidateLoader = new CandidateLoader(this, new CandidateLoader.LoggingErrorHandler(System.err)); candidateLoader.loadFromResource("org/objenesis/tck/candidates/standard-candidates.properties", Candidate.CandidateType.STANDARD); candidateLoader.loadFromResource("org/objenesis/tck/candidates/serializable-candidates.properties", Candidate.CandidateType.SERIALIZATION); } /** * 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, Candidate.CandidateType type) { Candidate candidate = new Candidate(candidateClass, description, type); int index = candidates.indexOf(candidate); if(index >= 0) { Candidate existingCandidate = candidates.get(index); if(!description.equals(existingCandidate.getDescription())) { throw new IllegalStateException("Two different descriptions for candidate " + candidateClass.getName()); } existingCandidate.getTypes().add(type); } else { candidates.add(candidate); } } /** * Run all TCK tests. */ public void runTests() { reporter.startTests(describePlatform(), objenesisStandard, objenesisSerializer); for(Candidate candidate : candidates) { reporter.startTest(candidate); if(candidate.getTypes().contains(Candidate.CandidateType.STANDARD)) { runTest(reporter, candidate.getClazz(), objenesisStandard, Candidate.CandidateType.STANDARD); } if(candidate.getTypes().contains(Candidate.CandidateType.SERIALIZATION)) { runTest(reporter, candidate.getClazz(), objenesisSerializer, Candidate.CandidateType.SERIALIZATION); } } reporter.endTests(); } private void runTest(Reporter reporter, Class candidate, Objenesis objenesis, Candidate.CandidateType type) { if(Feature.class.isAssignableFrom(candidate)) { runFeature(reporter, candidate, objenesis, type); } else { runCandidate(reporter, candidate, objenesis, type); } } private void runFeature(Reporter reporter, Class clazz, Objenesis objenesis, Candidate.CandidateType type) { try { @SuppressWarnings("unchecked") Constructor constructor = (Constructor) clazz.getConstructor(); Feature feature = constructor.newInstance(); boolean compliant = feature.isCompliant(objenesis); reporter.result(type, compliant); } catch(Exception e) { reporter.exception(type, e); } } private void runCandidate(Reporter reporter, Class candidate, Objenesis objenesis, Candidate.CandidateType type) { try { Object instance = objenesis.newInstance(candidate); boolean success = instance != null && instance.getClass() == candidate; reporter.result(type, success); } catch(Exception e) { reporter.exception(type, e); } } /** * 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 PlatformDescription.describePlatform(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/TextReporter.java000066400000000000000000000170401336222440400255560ustar00rootroot00000000000000/* * Copyright 2006-2018 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.List; import java.util.Map; import java.util.TreeMap; import org.objenesis.Objenesis; /** * Reports results from TCK as tabulated text, suitable for dumping to the console or a file and * being read by a human. * * @author Joe Walnes * @author Henri Tremblay * @see TCK * @see Reporter */ public class TextReporter implements Reporter { private static class Result { private final Candidate candidate; private final Candidate.CandidateType type; private final boolean result; private final Exception exception; /** * @param candidate Candidate tested * @param type Type of test performed * @param result If the test is successful or not * @param exception Exception that might have occurred during the test */ public Result(Candidate candidate, Candidate.CandidateType type, boolean result, Exception exception) { this.candidate = candidate; this.type = type; this.result = result; this.exception = exception; } } private final PrintStream summary; private final PrintStream log; private long startTime; private int errorCount; private Objenesis objenesisStandard; private Objenesis objenesisSerializer; private Candidate currentCandidate; private final Map> results = new TreeMap<>(); 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; } @Override public void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer) { this.platformDescription = platformDescription; this.objenesisStandard = objenesisStandard; this.objenesisSerializer = objenesisSerializer; this.currentCandidate = null; this.errorCount = 0; this.results.clear(); this.startTime = System.currentTimeMillis(); } @Override public void startTest(Candidate candidate) { currentCandidate = candidate; } @Override public void result(Candidate.CandidateType type, boolean success) { addResult(type, success, null); } @Override public void exception(Candidate.CandidateType type, Exception exception) { addResult(type, false, exception); } private void addResult(Candidate.CandidateType type, boolean success, Exception exception) { if(!success) { errorCount++; } Map result = results.computeIfAbsent(currentCandidate, k -> new HashMap<>()); result.put(type, new Result(currentCandidate, type, success, exception)); } @Override public void endTests() { long totalTime = System.currentTimeMillis() - startTime; printResult(totalTime); } /** * Print the final summary report * * @param totalTime Time spent running the TCK */ private void printResult(long totalTime) { // Platform summary.println("Running TCK on platform: " + platformDescription); summary.println(); // Instantiator implementations summary.println("Instantiators used: "); summary.println(" Objenesis standard : " + objenesisStandard.getInstantiatorOf(String.class).getClass().getName()); summary.println(" Objenesis serializer: " + objenesisSerializer.getInstantiatorOf(String.class).getClass().getName()); summary.println(); Collection candidateNames = new ArrayList<>(); for(Map.Entry> entry : results.entrySet()) { candidateNames.add(entry.getKey().getDescription()); } int maxObjenesisWidth = "Objenesis serializer".length(); int maxCandidateWidth = lengthOfLongestStringIn(candidateNames); // Strategy used summary.print(pad("", maxCandidateWidth) + ' '); summary.print(pad("Objenesis standard", maxObjenesisWidth) + ' '); summary.print(pad("Objenesis serializer", maxObjenesisWidth)); summary.println(); List exceptions = new ArrayList<>(); // Candidates for(Map.Entry> entry : results.entrySet()) { summary.print(pad(entry.getKey().getDescription(), maxCandidateWidth) + ' '); Result standardResult = entry.getValue().get(Candidate.CandidateType.STANDARD); Result serializationResult = entry.getValue().get(Candidate.CandidateType.SERIALIZATION); if(standardResult == null && serializationResult == null) { continue; } if(standardResult == null) { summary.print(pad("N/A", maxObjenesisWidth) + " "); } else { summary.print(pad(standardResult.result ? "Y" : "n", maxObjenesisWidth) + " "); if(standardResult.exception != null) { exceptions.add(standardResult); } } if(serializationResult == null) { summary.print(pad("N/A", maxObjenesisWidth)); } else { summary.print(pad(serializationResult.result ? "Y" : "n", maxObjenesisWidth)); if(serializationResult.exception != null) { exceptions.add(serializationResult); } } summary.println(); } summary.println(); // Final if(errorCount != 0) { for(Result element : exceptions) { log.println("--- Candidate '" + element.candidate.getDescription() + "', Type '" + element.type + "' ---"); element.exception.printStackTrace(log); log.println(); } log.println(); summary.println("--- FAILED: " + errorCount + " error(s) occurred ---"); } else { summary.println("--- SUCCESSFUL: TCK tests passed without errors in " + totalTime + " ms"); } summary.println(); } /** * Return true if the reporter has registered some errors * * @return if there was errors during execution */ public boolean hasErrors() { return errorCount != 0; } private String pad(String text, int width) { if(text.length() == width) { return text; } else if(text.length() > width) { return text.substring(0, width); } else { StringBuilder padded = new StringBuilder(text); while(padded.length() < width) { padded.append(' '); } return padded.toString(); } } private int lengthOfLongestStringIn(Collection descriptions) { int result = 0; for(String s : descriptions) { result = Math.max(result, s.length()); } return result; } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/000077500000000000000000000000001336222440400243415ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/ConstructorThrowingException.java000066400000000000000000000015401336222440400331320ustar00rootroot00000000000000/* * Copyright 2006-2018 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"); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/ConstructorWithArguments.java000066400000000000000000000017551336222440400322630ustar00rootroot00000000000000/* * Copyright 2006-2018 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; } } ConstructorWithMandatoryArguments.java000066400000000000000000000016171336222440400340600ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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"); } } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/DefaultPackageConstructor.java000066400000000000000000000014041336222440400323110ustar00rootroot00000000000000/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/DefaultPrivateConstructor.java000066400000000000000000000014141336222440400323710ustar00rootroot00000000000000/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/DefaultProtectedConstructor.java000066400000000000000000000014221336222440400327070ustar00rootroot00000000000000/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/DefaultPublicConstructor.java000066400000000000000000000014111336222440400321720ustar00rootroot00000000000000/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/NoConstructor.java000066400000000000000000000013201336222440400300220ustar00rootroot00000000000000/* * Copyright 2006-2018 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 { } SerializableConstructorThrowingException.java000066400000000000000000000017461336222440400354120ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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"); } } SerializableConstructorWithArguments.java000066400000000000000000000021631336222440400345250ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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; } } SerializableConstructorWithMandatoryArguments.java000066400000000000000000000020251336222440400364010ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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"); } } } SerializableDefaultPackageConstructor.java000066400000000000000000000016121336222440400345620ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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() { } } SerializableDefaultPrivateConstructor.java000066400000000000000000000016221336222440400346420ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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() { } } SerializableDefaultProtectedConstructor.java000066400000000000000000000016301336222440400351600ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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() { } } SerializableDefaultPublicConstructor.java000066400000000000000000000016171336222440400344520ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/SerializableNoConstructor.java000066400000000000000000000015061336222440400323570ustar00rootroot00000000000000/* * Copyright 2006-2018 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; } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/SerializableReplacer.java000066400000000000000000000016341336222440400312740ustar00rootroot00000000000000/* * Copyright 2006-2018 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(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/SerializableResolver.java000066400000000000000000000016331336222440400313370ustar00rootroot00000000000000/* * Copyright 2006-2018 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(); } } SerializableWithAncestorThrowingException.java000066400000000000000000000017011336222440400354660ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/candidates/* * Copyright 2006-2018 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() { } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/000077500000000000000000000000001336222440400240605ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/AbstractFeature.java000066400000000000000000000022331336222440400300020ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import java.util.ArrayList; import java.util.List; import org.objenesis.Objenesis; /** * Base class for features. It provides recording of calls. The recording is static * to the class so we expect {@link Feature#isCompliant(Objenesis)} multiple implementations to be called in * the same thread. * * @author Henri Tremblay */ public abstract class AbstractFeature implements Feature { protected static final List called = new ArrayList<>(); public AbstractFeature() { called.clear(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/ExtendsNotSerializableParentClass.java000066400000000000000000000025771336222440400335200ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import java.io.Serializable; import org.objenesis.Objenesis; /** * No-arg of the first none serializable parent class is called. * * @author Henri Tremblay */ public class ExtendsNotSerializableParentClass extends AbstractFeature { public static class ExtendsNotSerializable extends NotSerializableClass.NotSerializable implements Serializable { public ExtendsNotSerializable() { called.add(ExtendsNotSerializable.class.getSimpleName() + "."); } } @Override public boolean isCompliant(Objenesis objenesis) { objenesis.newInstance(ExtendsNotSerializable.class); return called.size() == 1 && called.get(0).equals(NotSerializableClass.NotSerializable.class.getSimpleName() + "."); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/ExtendsSerializableClass.java000066400000000000000000000023531336222440400316550ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import org.objenesis.Objenesis; /** * A class extending a serializable class can be instantiated without calling any constructor * * @author Henri Tremblay */ public class ExtendsSerializableClass extends AbstractFeature { public static class ExtendsSerializable extends SerializableClass.IsSerializable { public ExtendsSerializable() { called.add(ExtendsSerializable.class.getSimpleName() + "."); } } @Override public boolean isCompliant(Objenesis objenesis) { objenesis.newInstance(ExtendsSerializable.class); return called.isEmpty(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/Feature.java000066400000000000000000000017431336222440400263230ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import org.objenesis.Objenesis; /** * A feature is a behavior that we expect from an instantiator. For example, we expect a serializing instantiator * to call the no-arg constructor of the first none-serializable parent class. * * @author Henri Tremblay */ public interface Feature { boolean isCompliant(Objenesis objenesis); } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/NotSerializableClass.java000066400000000000000000000023721336222440400310040ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import org.objenesis.Objenesis; import org.objenesis.ObjenesisException; /** * Not serializable classes can't be instantiated. * * @author Henri Tremblay */ public class NotSerializableClass extends AbstractFeature { public static class NotSerializable { public NotSerializable() { called.add(NotSerializable.class.getSimpleName() + "."); } } @Override public boolean isCompliant(Objenesis objenesis) { try { objenesis.newInstance(NotSerializable.class); } catch(ObjenesisException e) { return true; } return false; } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/ReadExternalNotCalled.java000066400000000000000000000026621336222440400310750ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import java.io.Externalizable; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; import org.objenesis.Objenesis; /** * {@code Externalizable} methods should not be called during instantiation. * * @author Henri Tremblay */ public class ReadExternalNotCalled extends AbstractFeature { public static class ReadExternalAndAll implements Serializable, Externalizable { @Override public void writeExternal(ObjectOutput out) { called.add("writeExternal"); } @Override public void readExternal(ObjectInput in) { called.add("readExternal"); } } @Override public boolean isCompliant(Objenesis objenesis) { objenesis.newInstance(ReadExternalAndAll.class); return called.isEmpty(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/ReadObjectNotCalled.java000066400000000000000000000026241336222440400305170ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import java.io.Serializable; import org.objenesis.Objenesis; /** * {@code Serializable} special methods should not be called during instantiation. * * @author Henri Tremblay */ public class ReadObjectNotCalled extends AbstractFeature { public static class ReadObjectAndAll implements Serializable { private void readObject(java.io.ObjectInputStream in) { called.add("readObject"); } private Object readResolve() { called.add("readResolve"); return this; } private void readObjectNoData() { called.add("readObjectNoData"); } } @Override public boolean isCompliant(Objenesis objenesis) { objenesis.newInstance(ReadObjectAndAll.class); return called.isEmpty(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/features/SerializableClass.java000066400000000000000000000023111336222440400303140ustar00rootroot00000000000000/* * Copyright 2006-2018 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.features; import java.io.Serializable; import org.objenesis.Objenesis; /** * A serializable class can be instantiated without calling any constructor * * @author Henri Tremblay */ public class SerializableClass extends AbstractFeature { public static class IsSerializable implements Serializable { public IsSerializable() { called.add(Serializable.class.getSimpleName() + "."); } } @Override public boolean isCompliant(Objenesis objenesis) { objenesis.newInstance(IsSerializable.class); return called.isEmpty(); } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/search/000077500000000000000000000000001336222440400235075ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/search/ClassEnumerator.java000066400000000000000000000112531336222440400274630ustar00rootroot00000000000000/* * Copyright 2006-2018 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.search; import java.io.File; import java.io.IOException; import java.net.URL; import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; /** * Taken and adapted from here * * @author Henri Tremblay */ public class ClassEnumerator { private static void processDirectory(File directory, String pkgname, SortedSet classes) { // Get the list of the files contained in the package String[] files = directory.list(); for (String fileName : files) { // we are only interested in .class files if (fileName.endsWith(".class")) { // removes the .class extension String className = pkgname + '.' + fileName.substring(0, fileName.length() - 6); classes.add(className); continue; } File subdir = new File(directory, fileName); if (subdir.isDirectory()) { processDirectory(subdir, pkgname + '.' + fileName, classes); } } } private static void processJarfile(URL resource, String pkgname, SortedSet classes) { String relPath = pkgname.replace('.', '/'); String resPath = resource.getPath(); String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", ""); JarFile jarFile; try { jarFile = new JarFile(jarPath); } catch (IOException e) { throw new RuntimeException("Unexpected IOException reading JAR File '" + jarPath + "'", e); } Enumeration entries = jarFile.entries(); while(entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String entryName = entry.getName(); String className = null; if(entryName.endsWith(".class") && entryName.startsWith(relPath) && entryName.length() > (relPath.length() + "/".length())) { className = entryName.replace('/', '.').replace('\\', '.').replace(".class", ""); } if (className != null) { classes.add(className); } } } /** * Return all the classes in this package recursively. The class loader of the {@code ClassEnumerator} class * is used * * @param pkg the searched package * @return list of full class names */ public static SortedSet getClassesForPackage(Package pkg) { return getClassesForPackage(pkg, ClassEnumerator.class.getClassLoader()); } /** * Return all the classes in this package recursively. * * @param pkg the searched package * @param classLoader class loader where to look for classes * @return list of full class names */ public static SortedSet getClassesForPackage(Package pkg, ClassLoader classLoader) { SortedSet classes = new TreeSet<>(new Comparator() { public int compare(String o1, String o2) { String simpleName1 = getSimpleName(o1); String simpleName2 = getSimpleName(o2); return simpleName1.compareTo(simpleName2); } private String getSimpleName(String className) { return className.substring(className.lastIndexOf('.')); } }); String pkgname = pkg.getName(); String relPath = pkgname.replace('.', '/'); // Get a File object for the package Enumeration resources; try { resources = classLoader.getResources(relPath); } catch (IOException e) { throw new RuntimeException(e); } while(resources.hasMoreElements()) { URL resource = resources.nextElement(); if (resource.toString().startsWith("jar:")) { processJarfile(resource, pkgname, classes); } else { processDirectory(new File(resource.getPath()), pkgname, classes); } } return classes; } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/search/SearchWorkingInstantiator.java000066400000000000000000000061411336222440400315220ustar00rootroot00000000000000/* * Copyright 2006-2018 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.search; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.strategy.PlatformDescription; import org.objenesis.tck.candidates.SerializableNoConstructor; import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.SortedSet; /** * This class will try every available instantiator on the platform to see which works. * * @author Henri Tremblay */ public class SearchWorkingInstantiator implements Serializable { // implements Serializable just for the test private final SearchWorkingInstantiatorListener listener; public static void main(String[] args) { System.out.println(); System.out.println(PlatformDescription.describePlatform()); System.out.println(); SearchWorkingInstantiator searchWorkingInstantiator = new SearchWorkingInstantiator(new SystemOutListener()); searchWorkingInstantiator.searchForInstantiator(SerializableNoConstructor.class); } public SearchWorkingInstantiator(SearchWorkingInstantiatorListener listener) { this.listener = listener; } public void searchForInstantiator(Class toInstantiate) { SortedSet classes = ClassEnumerator.getClassesForPackage(ObjectInstantiator.class.getPackage()); for (String className : classes) { // Skip if inner class or isn't named like a instantiator if (className.contains("$") || !className.endsWith("Instantiator")) { continue; } Class c; try { c = Class.forName(className); } catch (Exception e) { listener.instantiatorNotFound(className, e); continue; } if (c.isInterface() || !ObjectInstantiator.class.isAssignableFrom(c)) { continue; } Constructor constructor; try { constructor = c.getConstructor(Class.class); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } try { ObjectInstantiator instantiator = (ObjectInstantiator) constructor.newInstance(toInstantiate); instantiator.newInstance(); listener.instantiatorSupported(c); } catch (Exception e) { Throwable t = (e instanceof InvocationTargetException) ? e.getCause() : e; listener.instantiatorUnsupported(c, t); } } } } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/search/SearchWorkingInstantiatorListener.java000066400000000000000000000016201336222440400332250ustar00rootroot00000000000000/* * Copyright 2006-2018 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.search; /** * @author Henri Tremblay */ public interface SearchWorkingInstantiatorListener { void instantiatorSupported(Class c); void instantiatorUnsupported(Class c, Throwable t); void instantiatorNotFound(String className, Throwable t); } objenesis-3.0.1/tck/src/main/java/org/objenesis/tck/search/SystemOutListener.java000066400000000000000000000031561336222440400300410ustar00rootroot00000000000000/* * Copyright 2006-2018 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.search; import org.objenesis.instantiator.annotations.Instantiator; import org.objenesis.instantiator.annotations.Typology; /** * @author Henri Tremblay */ public class SystemOutListener implements SearchWorkingInstantiatorListener { private static final String PATTERN = "%-65s: %s%n"; public void instantiatorSupported(Class c) { System.out.printf(PATTERN, c.getSimpleName() + " (" + getTypology(c) + ")", "Working!"); } public void instantiatorUnsupported(Class c, Throwable t) { System.out.printf(PATTERN, c.getSimpleName() + "(" + getTypology(c) + ")", "KO - " + t); } @Override public void instantiatorNotFound(String className, Throwable t) { System.out.printf(PATTERN, className + " not found", "KO - " + t); } private Typology getTypology(Class c) { Instantiator instantiatorAnn = c.getAnnotation(Instantiator.class); return instantiatorAnn == null ? Typology.UNKNOWN : instantiatorAnn.value(); } } objenesis-3.0.1/tck/src/main/resources/000077500000000000000000000000001336222440400200025ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/resources/org/000077500000000000000000000000001336222440400205715ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/resources/org/objenesis/000077500000000000000000000000001336222440400225525ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/resources/org/objenesis/tck/000077500000000000000000000000001336222440400233335ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/resources/org/objenesis/tck/candidates/000077500000000000000000000000001336222440400254325ustar00rootroot00000000000000serializable-candidates.properties000066400000000000000000000052221336222440400342350ustar00rootroot00000000000000objenesis-3.0.1/tck/src/main/resources/org/objenesis/tck/candidates# # Copyright 2006-2018 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) # Features we want from a Serialization instantiator. org.objenesis.tck.features.SerializableClass = Serializable class calls no constructor org.objenesis.tck.features.ExtendsSerializableClass = Extending a serializable class calls no constructor org.objenesis.tck.features.NotSerializableClass = Not serializable class fail org.objenesis.tck.features.ExtendsNotSerializableParentClass = None-serializable parent no-arg constructor called org.objenesis.tck.features.ReadObjectNotCalled = Serialization special methods not called org.objenesis.tck.features.ReadExternalNotCalled = Externalizable readExternal() not called objenesis-3.0.1/tck/src/main/resources/org/objenesis/tck/candidates/standard-candidates.properties000066400000000000000000000057231336222440400334540ustar00rootroot00000000000000# # Copyright 2006-2018 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) objenesis-3.0.1/tck/src/test/000077500000000000000000000000001336222440400160235ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/java/000077500000000000000000000000001336222440400167445ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/java/org/000077500000000000000000000000001336222440400175335ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/java/org/objenesis/000077500000000000000000000000001336222440400215145ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/000077500000000000000000000000001336222440400222755ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/AbstractLoaderTest.java000066400000000000000000000077671336222440400267130ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.junit.Before; import org.junit.Test; import static org.junit.Assert.*; /** * @author Henri Tremblay * @author Joe Walnes */ public class AbstractLoaderTest { private StringBuilder recordedEvents; private AbstractLoader loader; @Before public void setUp() { recordedEvents = new StringBuilder(); AbstractLoader.ErrorHandler errorHandler = name -> recordedEvents.append("classNotFound('").append(name).append("')\n"); loader = new AbstractLoader(getClass().getClassLoader(), errorHandler) { @Override protected void handlePropertyEntry(Class clazz, String description, Candidate.CandidateType type) { recordedEvents.append("registerCandidate('class " + clazz.getName() + "', '" + description + "')\n"); } }; } @Test public void testReadsClassesAndDescriptionsFromPropertiesFile() throws IOException { String input = "" + "org.objenesis.tck.AbstractLoaderTest$A = A candidate\n" + "\n" + "# a comment and some whitespace\n" + "\n" + "org.objenesis.tck.AbstractLoaderTest$B = B candidate\n" + "org.objenesis.tck.AbstractLoaderTest$C = C candidate\n"; loader.loadFrom(new ByteArrayInputStream(input.getBytes()), Candidate.CandidateType.STANDARD); assertEquals("" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$A', 'A candidate')\n" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$B', 'B candidate')\n" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$C', 'C candidate')\n", recordedEvents.toString()); } @Test public void testReportsMissingClassesToErrorHandler() throws IOException { String input = "" + "org.objenesis.tck.AbstractLoaderTest$A = A candidate\n" + "org.objenesis.tck.AbstractLoaderTest$NonExistent = Dodgy candidate\n" + "org.objenesis.tck.AbstractLoaderTest$C = C candidate\n"; loader.loadFrom(new ByteArrayInputStream(input.getBytes()), Candidate.CandidateType.STANDARD); assertEquals("" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$A', 'A candidate')\n" + "classNotFound('org.objenesis.tck.AbstractLoaderTest$NonExistent')\n" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$C', 'C candidate')\n", recordedEvents.toString()); } @Test public void testLoadsFromResourceInClassPath() throws IOException { // See CandidateLoaderTest-sample.properties. loader.loadFromResource("org/objenesis/tck/CandidateLoaderTest-sample.properties", Candidate.CandidateType.STANDARD); assertEquals("" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$A', 'A candidate')\n" + "registerCandidate('class org.objenesis.tck.AbstractLoaderTest$B', 'B candidate')\n", recordedEvents.toString()); } @Test public void testThrowsIOExceptionIfResourceNotInClassPath() { try { loader.loadFromResource( "Blatantly-Bogus.properties", Candidate.CandidateType.STANDARD); fail("Expected exception"); } catch(IOException expectedException) { // Good! } } // Sample classes. public static class A { } public static class B { } public static class C { } } objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/ObjenesisTest.java000066400000000000000000000043471336222440400257310ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.junit.Test; import org.objenesis.Objenesis; import org.objenesis.ObjenesisSerializer; import org.objenesis.ObjenesisStd; import static org.junit.Assert.*; /** * Integration test for Objenesis. Should pass successfully on every supported JVM for all Objenesis * interface implementation. * * @author Henri Tremblay */ public class ObjenesisTest { public static class JUnitReporter implements Reporter { private Candidate currentCandidate; @Override public void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer) { } @Override public void startTest(Candidate candidate) { currentCandidate = candidate; } @Override public void result(Candidate.CandidateType type, boolean worked) { assertTrue("Instantiating " + currentCandidate + " for " + type + " failed", worked); } @Override public void exception(Candidate.CandidateType type, Exception exception) { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try (PrintStream out = new PrintStream(buffer)) { out.println("Exception when instantiating " + currentCandidate + " for " + type + ": "); exception.printStackTrace(out); fail(buffer.toString()); } } @Override public void endTests() { } } @Test public void test() { TCK tck = new TCK(new ObjenesisStd(), new ObjenesisSerializer(), new JUnitReporter()); tck.runTests(); } } objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/OsgiTest.java000066400000000000000000000066031336222440400247060ustar00rootroot00000000000000/* * Copyright 2006-2018 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.File; import java.io.Serializable; import org.junit.Test; import org.junit.runner.RunWith; import org.objenesis.Objenesis; import org.objenesis.ObjenesisHelper; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerMethod; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; import javax.xml.xpath.XPathFactory; import static org.junit.Assert.*; import static org.ops4j.pax.exam.CoreOptions.*; /** * @author Henri Tremblay */ @RunWith(PaxExam.class) @ExamReactorStrategy(PerMethod.class) public class OsgiTest implements Serializable{ private static final long serialVersionUID = 1L; @Configuration public Option[] config() { String version = getImplementationVersion(Objenesis.class); return options( bundle("file:../main/target/objenesis-" + version + ".jar"), junitBundles() ); } @Test public void testCanInstantiate() { assertSame(OsgiTest.class, ObjenesisHelper.newInstance(getClass()).getClass()); } @Test public void testCanInstantiateSerialize() { assertSame(OsgiTest.class, ObjenesisHelper.newSerializableInstance(getClass()).getClass()); } private String getImplementationVersion(final Class c) { String version = c.getPackage().getImplementationVersion(); // Null means we are an IDE, not in Maven. So we have an IDE project dependency instead // of a Maven dependency with the jar. Which explains why the version is null (no Manifest // since there's no jar). In that case we get the version from the pom.xml. if(version == null) { try { XPathFactory xPathFactory = XPathFactory.newInstance(); final XPath xPath = xPathFactory.newXPath(); XPathExpression xPathExpression; try { xPathExpression = xPath.compile("/project/parent/version"); } catch(final XPathExpressionException e) { throw new RuntimeException(e); } final DocumentBuilderFactory xmlFact = DocumentBuilderFactory.newInstance(); xmlFact.setNamespaceAware(false); final DocumentBuilder builder = xmlFact.newDocumentBuilder(); final Document doc = builder.parse(new File("pom.xml")); version = xPathExpression.evaluate(doc); } catch(final Exception e) { throw new RuntimeException(e); } } return version; } } objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/SerializableTest.java000066400000000000000000000173341336222440400264160ustar00rootroot00000000000000/* * Copyright 2006-2018 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.ByteArrayOutputStream; import java.io.Externalizable; import java.io.IOException; import java.io.NotSerializableException; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.io.Serializable; import java.util.HashSet; import java.util.Set; import org.junit.After; import org.junit.Test; import static org.junit.Assert.*; /** * Test showcasing how the normal serialization should behave (constructor and special methods called). You * can use it to compare with an instantiator to see how it mimics it. * * @author Henri Tremblay */ public class SerializableTest { public static class IsSerializable implements Serializable { public IsSerializable() { called.add("IsSerializable.constructor"); } } public static class ExtendsSerializable extends IsSerializable { public ExtendsSerializable() { called.add("ExtendsSerializable.constructor"); } } public static class NotSerializable { public NotSerializable() { called.add("NotSerializable.constructor"); } } public static class ExtendsNotSerializableButIs extends NotSerializable implements Serializable { public ExtendsNotSerializableButIs() { called.add("ExtendsNotSerializableButIs.constructor"); } } public static class IsExternalizable implements Externalizable { public IsExternalizable() { called.add("IsExternalizable.constructor"); } @Override public void writeExternal(ObjectOutput out) { called.add("IsExternalizable.write"); } @Override public void readExternal(ObjectInput in) { called.add("IsExternalizable.read"); } private Object writeReplace() { called.add("IsExternalizable.writeReplace"); return this; } private Object readResolve() { called.add("IsExternalizable.readResolve"); return this; } } public static class IsExternalizableAndSerializable implements Externalizable, Serializable { public IsExternalizableAndSerializable() { called.add("IsExternalizableAndSerializable.constructor"); } @Override public void writeExternal(ObjectOutput out) { called.add("IsExternalizableAndSerializable.write"); } @Override public void readExternal(ObjectInput in) { called.add("IsExternalizableAndSerializable.read"); } } public static class IsExternalizableButExtends extends ExtendsNotSerializableButIs implements Externalizable { public IsExternalizableButExtends() { called.add("IsExternalizableButExtends.constructor"); } @Override public void writeExternal(ObjectOutput out) { called.add("IsExternalizableButExtends.write"); } @Override public void readExternal(ObjectInput in) { called.add("IsExternalizableButExtends.read"); } } public static class ReadWriteObject implements Serializable { public ReadWriteObject() { called.add("ReadWriteObject.constructor"); } // Write the object to the stream private void writeObject(java.io.ObjectOutputStream out) { called.add("ReadWriteObject.write"); } // Read the object from the stream private void readObject(java.io.ObjectInputStream in) { called.add("ReadWriteObject.read"); } } public static class ReadWriteReplace implements Serializable { public ReadWriteReplace() { called.add("ReadWriteReplace.constructor"); } private Object writeReplace() { called.add("ReadWriteReplace.write"); return this; } private Object readResolve() { called.add("ReadWriteReplace.read"); return this; } } private static final Set called = new HashSet<>(); @After public void verify() { assertTrue(called.toString(), called.isEmpty()); } @Test public void isSerializable() throws Exception { writeRead(new IsSerializable()); assertNotCalled("IsSerializable.constructor"); } @Test public void extendsSerializable() throws Exception { writeRead(new ExtendsSerializable()); assertNotCalled("IsSerializable.constructor"); assertNotCalled("ExtendsSerializable.constructor"); } @Test public void notSerializable() throws Exception { try { writeRead(new NotSerializable()); fail("Class is not serializable so can't be read"); } catch(NotSerializableException e) { } assertNotCalled("NotSerializable.constructor"); } @Test public void extendsNotSerializable() throws Exception { writeRead(new ExtendsNotSerializableButIs()); assertCalled("NotSerializable.constructor"); assertNotCalled("ExtendsNotSerializableButIs.constructor"); } @Test public void isExternalizable() throws Exception { writeRead(new IsExternalizable()); assertCalled("IsExternalizable.constructor"); assertCalled("IsExternalizable.read"); assertCalled("IsExternalizable.write"); assertCalled("IsExternalizable.writeReplace"); assertCalled("IsExternalizable.readResolve"); } @Test public void isExternalizableAndSerializable() throws Exception { writeRead(new IsExternalizableAndSerializable()); assertCalled("IsExternalizableAndSerializable.constructor"); assertCalled("IsExternalizableAndSerializable.read"); assertCalled("IsExternalizableAndSerializable.write"); } @Test public void isExternalizableButExtends() throws Exception { writeRead(new IsExternalizableButExtends()); assertCalled("NotSerializable.constructor"); assertCalled("ExtendsNotSerializableButIs.constructor"); assertCalled("IsExternalizableButExtends.constructor"); assertCalled("IsExternalizableButExtends.read"); assertCalled("IsExternalizableButExtends.write"); } @Test public void readWriteObject() throws Exception { writeRead(new ReadWriteObject()); assertNotCalled("ReadWriteObject.constructor"); assertCalled("ReadWriteObject.read"); assertCalled("ReadWriteObject.write"); } @Test public void readWriteReplace() throws Exception { writeRead(new ReadWriteReplace()); assertNotCalled("ReadWriteReplace.constructor"); assertCalled("ReadWriteReplace.read"); assertCalled("ReadWriteReplace.write"); } private void assertCalled(String s) { assertTrue(called.remove(s)); } private void assertNotCalled(String s) { assertFalse(called.remove(s)); } private void writeRead(Object s) throws IOException, ClassNotFoundException { called.clear(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bOut); out.writeObject(s); out.close(); byte[] buffer = bOut.toByteArray(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer)); in.readObject(); in.close(); } } objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/TCKTest.java000066400000000000000000000141001336222440400244150ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.junit.Test; import org.objenesis.Objenesis; import org.objenesis.instantiator.ObjectInstantiator; import org.objenesis.tck.features.Feature; import static org.junit.Assert.*; /** * @author Joe Walnes * @author Henri Tremblay */ public class TCKTest { public static class StubbedInstantiator implements Objenesis { public T newInstance(Class clazz) { return null; } public ObjectInstantiator getInstantiatorOf(Class clazz) { return null; } } @Test public void testReportsAllCandidatesAndInstantiatorCombinationsToReporter() { Reporter reporter = new RecordingReporter(); // Given... a TCK with some candidate classes: A, B and C. TCK tck = new TCK(new StubbedInstantiator(), new StubbedInstantiator(), reporter) { @Override protected void loadCandidates() { registerCandidate(CandidateA.class, "Candidate A", Candidate.CandidateType.STANDARD); registerCandidate(CandidateB.class, "Candidate B", Candidate.CandidateType.STANDARD); registerCandidate(CandidateB.class, "Candidate B", Candidate.CandidateType.SERIALIZATION); registerCandidate(CandidateC.class, "Candidate C", Candidate.CandidateType.STANDARD); } }; // When... the TCK tests are run tck.runTests(); // Expect... the reporter to have received a sequence of calls // notifying it of what the TCK is doing. assertEquals("" + "startTests()\n" + "startTest('Candidate A')\nresult(STANDARD, false)\n" + "startTest('Candidate B')\nresult(STANDARD, false)\nresult(SERIALIZATION, false)\n" + "startTest('Candidate C')\nresult(STANDARD, false)\n" + "endTests()\n", reporter.toString()); } @Test public void testReportsSuccessIfCandidateCanBeInstantiated() { // When... the TCK tests are run Reporter reporter = new RecordingReporter(); // Given... a TCK with some candidate classes: A, B and C. TCK tck = new TCK(new SelectiveInstantiator(), new SelectiveInstantiator(), reporter) { @Override protected void loadCandidates() { registerCandidate(CandidateA.class, "Candidate A", Candidate.CandidateType.STANDARD); registerCandidate(CandidateA.class, "Candidate A", Candidate.CandidateType.SERIALIZATION); registerCandidate(CandidateB.class, "Candidate B", Candidate.CandidateType.STANDARD); registerCandidate(CandidateB.class, "Candidate B", Candidate.CandidateType.SERIALIZATION); registerCandidate(CandidateC.class, "Candidate C", Candidate.CandidateType.STANDARD); registerCandidate(CandidateD.class, "Candidate D", Candidate.CandidateType.SERIALIZATION); } }; tck.runTests(); // Expect... the reporter to be notified that A succeeded // but B failed. assertEquals("" + "startTests()\n" + "startTest('Candidate A')\nresult(STANDARD, true)\nresult(SERIALIZATION, true)\n" + "startTest('Candidate B')\nresult(STANDARD, false)\nresult(SERIALIZATION, false)\n" + "startTest('Candidate C')\nexception(STANDARD)\n" + "startTest('Candidate D')\nresult(SERIALIZATION, true)\n" + "endTests()\n", reporter.toString()); } // Some sample classes used for testing. public static class SelectiveInstantiator implements Objenesis { public T newInstance(Class clazz) { if(clazz == CandidateA.class) { return clazz.cast(new CandidateA()); } if(clazz == CandidateC.class) { throw new RuntimeException("fail"); } return null; } public ObjectInstantiator getInstantiatorOf(Class clazz) { return null; } } public static class CandidateA { } public static class CandidateB { } public static class CandidateC { } public static class CandidateD implements Feature { @Override public boolean isCompliant(Objenesis objenesis) { return true; } } /** * 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 StringBuilder log = new StringBuilder(); @Override public void startTests(String platformDescription, Objenesis objenesisStandard, Objenesis objenesisSerializer) { log.append("startTests()\n"); } @Override public void startTest(Candidate candidate) { log.append("startTest('").append(candidate.getDescription()).append("')\n"); } @Override public void result(Candidate.CandidateType type, boolean worked) { log.append("result(").append(type).append(", ").append(worked).append(")\n"); } @Override public void exception(Candidate.CandidateType type, Exception exception) { log.append("exception(").append(type).append(")\n"); } @Override public void endTests() { log.append("endTests()\n"); } @Override public String toString() { return log.toString(); } } } objenesis-3.0.1/tck/src/test/java/org/objenesis/tck/TextReporterTest.java000066400000000000000000000076531336222440400264620ustar00rootroot00000000000000/* * Copyright 2006-2018 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 org.junit.Before; import org.junit.Test; import org.objenesis.Objenesis; import org.objenesis.ObjenesisBase; import org.objenesis.instantiator.basic.ConstructorInstantiator; import org.objenesis.instantiator.basic.FailingInstantiator; import org.objenesis.strategy.SingleInstantiatorStrategy; import static org.junit.Assert.*; /** * @author Joe Walnes * @author Henri Tremblay */ public class TextReporterTest { private TextReporter textReporter; private ByteArrayOutputStream summaryBuffer; @Before public void setUp() { summaryBuffer = new ByteArrayOutputStream(); ByteArrayOutputStream logBuffer = new ByteArrayOutputStream(); textReporter = new TextReporter(new PrintStream(summaryBuffer), new PrintStream(logBuffer)); } @Test public void testReportsSuccessesInTabularFormat() { Objenesis instantiator1 = new ObjenesisBase(new SingleInstantiatorStrategy( ConstructorInstantiator.class)); Objenesis instantiator2 = new ObjenesisBase(new SingleInstantiatorStrategy( FailingInstantiator.class)); textReporter.startTests("Some platform", instantiator1, instantiator2); textReporter.startTest(new Candidate(TCKTest.CandidateA.class, "candidate A", Candidate.CandidateType.STANDARD, Candidate.CandidateType.SERIALIZATION)); textReporter.result(Candidate.CandidateType.STANDARD,false); textReporter.result(Candidate.CandidateType.SERIALIZATION, true); textReporter.startTest(new Candidate(TCKTest.CandidateB.class, "candidate B", Candidate.CandidateType.STANDARD)); textReporter.result(Candidate.CandidateType.STANDARD,true); textReporter.startTest(new Candidate(TCKTest.CandidateC.class,"candidate C", Candidate.CandidateType.STANDARD, Candidate.CandidateType.SERIALIZATION)); textReporter.exception(Candidate.CandidateType.STANDARD, new RuntimeException("Problem")); textReporter.result(Candidate.CandidateType.SERIALIZATION, false); textReporter.startTest(new Candidate(TCKTest.CandidateD.class,"candidate D", Candidate.CandidateType.SERIALIZATION)); textReporter.result(Candidate.CandidateType.SERIALIZATION, true); textReporter.endTests(); ByteArrayOutputStream expectedSummaryBuffer = new ByteArrayOutputStream(); PrintStream out = new PrintStream(expectedSummaryBuffer); out.println("Running TCK on platform: Some platform"); out.println(); out.println("Instantiators used: "); out.println(" Objenesis standard : org.objenesis.instantiator.basic.ConstructorInstantiator"); out.println(" Objenesis serializer: org.objenesis.instantiator.basic.FailingInstantiator"); out.println(); out.println(" Objenesis standard Objenesis serializer"); out.println("candidate A n Y "); out.println("candidate B Y N/A "); out.println("candidate C n n "); out.println("candidate D N/A Y "); out.println(); out.println("--- FAILED: 3 error(s) occurred ---"); out.println(); assertEquals(expectedSummaryBuffer.toString(), summaryBuffer.toString()); } } objenesis-3.0.1/tck/src/test/resources/000077500000000000000000000000001336222440400200355ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/resources/logback-test.xml000066400000000000000000000016351336222440400231430ustar00rootroot00000000000000 %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n objenesis-3.0.1/tck/src/test/resources/org/000077500000000000000000000000001336222440400206245ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/resources/org/objenesis/000077500000000000000000000000001336222440400226055ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/resources/org/objenesis/tck/000077500000000000000000000000001336222440400233665ustar00rootroot00000000000000objenesis-3.0.1/tck/src/test/resources/org/objenesis/tck/CandidateLoaderTest-sample.properties000066400000000000000000000013461336222440400326320ustar00rootroot00000000000000# # Copyright 2006-2018 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.AbstractLoaderTest$A = A candidate org.objenesis.tck.AbstractLoaderTest$B = B candidate objenesis-3.0.1/website/000077500000000000000000000000001336222440400151365ustar00rootroot00000000000000objenesis-3.0.1/website/.project000066400000000000000000000016771336222440400166200ustar00rootroot00000000000000 objenesis-website org.eclipse.wst.jsdt.core.javascriptValidator org.eclipse.wst.common.project.facet.core.builder org.eclipse.wst.validation.validationbuilder org.eclipse.m2e.core.maven2Builder org.eclipse.m2e.core.maven2Nature org.eclipse.wst.common.project.facet.core.nature org.eclipse.wst.common.modulecore.ModuleCoreNature org.eclipse.wst.jsdt.core.jsNature objenesis-3.0.1/website/.settings/000077500000000000000000000000001336222440400170545ustar00rootroot00000000000000objenesis-3.0.1/website/.settings/org.eclipse.core.resources.prefs000066400000000000000000000007431336222440400252730ustar00rootroot00000000000000eclipse.preferences.version=1 encoding//site/content/acknowledgements.html=UTF-8 encoding//site/content/details.html=UTF-8 encoding//site/content/download.html=UTF-8 encoding//site/content/embedding.html=UTF-8 encoding//site/content/index.html=UTF-8 encoding//site/content/license.html=UTF-8 encoding//site/content/notes.html=UTF-8 encoding//site/content/source.html=UTF-8 encoding//site/content/support.html=UTF-8 encoding//site/content/tutorial.html=UTF-8 encoding/=UTF-8 objenesis-3.0.1/website/pom.xml000066400000000000000000000077051336222440400164640ustar00rootroot00000000000000 4.0.0 org.objenesis objenesis-parent 3.0.1 objenesis-website Objenesis website pom 3.0.1 apidocs org.objenesis objenesis 3.0.1 com.keyboardsamurais.maven maven-timestamp-plugin maven-resources-plugin copy-resources prepare-package copy-resources ${project.build.directory}/site \ UTF-8 ${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.3 ${project.build.directory}/site content/sitemap.xml templates/skin.html resources ${project.build.directory}/xsite package run maven-deploy-plugin true objenesis-3.0.1/website/site/000077500000000000000000000000001336222440400161025ustar00rootroot00000000000000objenesis-3.0.1/website/site/content/000077500000000000000000000000001336222440400175545ustar00rootroot00000000000000objenesis-3.0.1/website/site/content/acknowledgements.html000066400000000000000000000053371336222440400240040ustar00rootroot00000000000000 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

objenesis-3.0.1/website/site/content/details.html000066400000000000000000000175001336222440400220720ustar00rootroot00000000000000 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 your 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 on 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 against 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 the 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.

Android

Objenesis also works on Dalvik, the Android VM. So a TCK is also provided for it in the form of an apk. You can also find it on download page. Just use the following command to install and run it.

adb install -r objenesis-tck-android-${project.version}.apk
adb shell am instrument -w org.objenesis.tck.android/.TckInstrumentation

Exception Handling

If something wrong occurs using Objenesis, you will normally get an ObjenesisException wrapping 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 possibly 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 for 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());
    }
}

Also, if Objenesis can't find the right instantiator to use by itself, this doesn't mean it doesn't bundle an instantiator that works on your platform. To try to find one, we provide a nice tool that will run through all the instantiators and tell you which ones work

java -cp objenesis-${project.version}-tck.jar org.objenesis.tck.search.SearchWorkingInstantiator

Some culprits:

  • Some instantiators are made to mimic the Java serialization. It means they will call the default constructor of the first non-serializable class
  • Some instantiators only works if the class is serializable
  • Some instantiators will in fact call the default constructor
  • Depending on your security manager, classes coming from a low level class loader might not be instantiable

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);

Serializing instantiator details

The instantiator returned by SerializingInstantiatorStrategy will do the following.

  • Fail is the class is not serializable
  • Call the no-arg constructor of the first none serializable class. Just like the serialization would do
  • Externalizable classes won't have a special treatment. If you want one, implement it yourself
  • No serializable specific method is called (e.g. readResolve, readExternal, readObject, readObjectNoData)
objenesis-3.0.1/website/site/content/download.html000066400000000000000000000032321336222440400222510ustar00rootroot00000000000000 Download

Current version is ${project.version}

Older versions can be found here

objenesis-3.0.1/website/site/content/embedding.html000066400000000000000000000057271336222440400223730ustar00rootroot00000000000000 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>
objenesis-3.0.1/website/site/content/index.html000066400000000000000000000073241336222440400215570ustar00rootroot00000000000000 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 overcome 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 instantiated in non-standard ways.

Getting Started

  1. Download Objenesis.
  2. Read the twenty second tutorial.

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.

Benchmarking

We do more and more benchmarking to make sure Objenesis has great performance but also to settled the best way to use it for multiple use-cases. Results are added here. Please, share your own results. Especially, if they differ from ours.

objenesis-3.0.1/website/site/content/license.html000066400000000000000000000042501336222440400220650ustar00rootroot00000000000000 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-2013, 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.
objenesis-3.0.1/website/site/content/notes.html000066400000000000000000000105201336222440400215700ustar00rootroot00000000000000 Release notes

Version 3.0.1 (2018-10-18)

  • No Automatic-Module-Name in objenesis (#66)

Version 3.0 (2018-10-07)

  • Drop JRockit support (#64)
  • Move lower support to Java 1.8 (#63)
  • Replace findbugs by spotbugs (#62)
  • ClassDefinitionUtils doesn't compile with Java 11 (#61)
  • update pom.xml for maven plugins (#60)
  • Test errors with Java 10 (#59)
  • Please remove the hidden .mvn directory from the source tarball (#57)
  • Move Android TCK API 26 because objenesis now requires it (#65(

Version 2.6 (2017-06-20)

  • App Engine Java 8 Runtime support (#51)
  • Improve Java 9 support (#53)
  • Clarify serialization strategy behavior enhancement (#54)
  • SunReflectionFactoryInstantiator not working if parent class constructor isn't public (#33)
  • Validate Android O (#52)
  • Drop Java 5 support (#55)

Version 2.5.1 (2017-01-17)

  • Test failure: org.objenesis.instantiator.basic.ClassDefinitionUtilsTest on debian (#49)

Version 2.5 (2017-01-12)

  • Support JDK 9 (tested on 9-ea+151-jigsaw) (#45)
  • Expose MagicInstantiator internal ObjectInstantiator (#43)
  • Move OSGi tests to Pax-Exam

Version 2.4 (2016-05-23)

  • Objenesis license incompatible with EPL (#40)
  • Tests of the Android TCK are never failing (#41)

Version 2.3 (2016-05-10)

  • Android N : standard android instantiators don't work (#37)
  • Fixed an issue with Android N's OpenJDK where invalid instantiator is picked (#38)
  • Build fail on old versions because of license check (#39)

Version 2.2 (2015-07-24)

  • New SearchWorkingInstantiator allowing to identify which instantiator can work on a platform (#34)
  • JVM_NAME is used instead of VENDOR (#32)
  • sun.misc missing from Import-Package header in manifest (#31)
  • New ProxyInstantiator extending a class to bypass the super constructor (#23)
  • New MagicInstantiator using MagicAccessorImpl (#35)
  • Partial Google App Engine support. See here (#15)

Version 2.1 (2013-10-10)

  • Support for Android API level 18 (#23)
  • Have the tck returning a value different from zero in case of failures (#24)
  • Make it easier to call the TCK programmatically (#25)
  • Show the actual instantiator implementation used by the TCK (#26)
  • Explicit support for OpenJDK (#27)

Version 2.0 (2013-08-21)

  • Upgrade to Java 5 (#21)
  • Remove synchronization requirement when retrieving an instantiator from cache (#22)

Version 1.4 (2013-08-16)

  • Android Gingerbread support (#18)
  • New instantiator using Unsafe.allocateInstance() (#19)
  • Optimisation when instantiator cache isn't used (#14)

Version 1.3 (2013-01-23)

  • Dalvik (Android) support (#13)
  • Android TCK (#13)
  • Allow to compile on any JVM (#13)

Version 1.2 (2010-03-15)

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

Version 1.1 (2007-12-09)

  • Standard support of Aonix PERC (no Serialization support)

Version 1.0 (2007-02-14)

  • Initial version, support for Sun Hotspot, GCJ and BEA JRockit JVMs
objenesis-3.0.1/website/site/content/sitemap.xml000066400000000000000000000023011336222440400217340ustar00rootroot00000000000000
Objenesis index.html license.html download.html
Documentation tutorial.html details.html embedding.html
Project Details support.html acknowledgements.html source.html notes.html who.html
objenesis-3.0.1/website/site/content/source.html000066400000000000000000000015711336222440400217460ustar00rootroot00000000000000 Source Repository

The source repository for Objenesis is hosted by GitHub.

objenesis-3.0.1/website/site/content/support.html000066400000000000000000000017651336222440400221670ustar00rootroot00000000000000 Getting Support objenesis-3.0.1/website/site/content/tutorial.html000066400000000000000000000102251336222440400223050ustar00rootroot00000000000000 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, specific implementation methods (e.g. readResolve()) are 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();
objenesis-3.0.1/website/site/content/who.html000066400000000000000000000022231336222440400212360ustar00rootroot00000000000000 Who is using Objenesis

Objenesis is currently used by many nice frameworks you should probably try if you haven't yet. We list some of them below.

objenesis-3.0.1/website/site/resources/000077500000000000000000000000001336222440400201145ustar00rootroot00000000000000objenesis-3.0.1/website/site/resources/.nojekyll000066400000000000000000000000001336222440400217320ustar00rootroot00000000000000objenesis-3.0.1/website/site/resources/CNAME000066400000000000000000000000161336222440400206570ustar00rootroot00000000000000objenesis.org objenesis-3.0.1/website/site/resources/googlefda9c590a38fa17b.html000066400000000000000000000012511336222440400245570ustar00rootroot00000000000000 google-site-verification: googlefda9c590a38fa17b.htmlobjenesis-3.0.1/website/site/resources/objenesis-logo.png000066400000000000000000000137511336222440400235500ustar00rootroot00000000000000PNG  IHDRHHUG pHYs   OiCCPPhotoshop ICC profilexڝSgTS=BKKoR RB&*! J!QEEȠQ, !{kּ> H3Q5 B.@ $pd!s#~<<+"x M0B\t8K@zB@F&S`cbP-`'{[! eDh;VEX0fK9-0IWfH  0Q){`##xFW<+*x<$9E[-qWW.(I+6aa@.y24x6_-"bbϫp@t~,/;m%h^ uf@Wp~<5j>{-]cK'Xto(hw?G%fIq^D$.Tʳ?D*A, `6B$BB dr`)B(Ͱ*`/@4Qhp.U=pa( Aa!ڈbX#!H$ ɈQ"K5H1RT UH=r9\F;2G1Q= C7F dt1r=6Ыhڏ>C03l0.B8, c˱" VcϱwE 6wB aAHXLXNH $4 7 Q'"K&b21XH,#/{C7$C2'ITFnR#,4H#dk9, +ȅ3![ b@qS(RjJ4e2AURݨT5ZBRQ4u9̓IKhhitݕNWGw Ljg(gwLӋT071oUX**| J&*/Tު UUT^S}FU3S ԖUPSSg;goT?~YYLOCQ_ cx,!k u5&|v*=9C3J3WRf?qtN (~))4L1e\kXHQG6EYAJ'\'GgSSݧ M=:.kDwn^Loy}/TmG X $ <5qo</QC]@Caaᄑ.ȽJtq]zۯ6iܟ4)Y3sCQ? 0k߬~OCOg#/c/Wװwa>>r><72Y_7ȷOo_C#dz%gA[z|!?:eAAA!h쐭!ΑiP~aa~ 'W?pX15wCsDDDޛg1O9-J5*>.j<74?.fYXXIlK9.*6nl {/]py.,:@LN8A*%w% yg"/6шC\*NH*Mz쑼5y$3,幄'L Lݛ:v m2=:1qB!Mggfvˬen/kY- BTZ(*geWf͉9+̳ې7ᒶKW-X潬j9(xoʿܔĹdff-[n ڴ VE/(ۻCɾUUMfeI?m]Nmq#׹=TR+Gw- 6 U#pDy  :v{vg/jBFS[b[O>zG499?rCd&ˮ/~јѡ򗓿m|x31^VwwO| (hSЧc3- cHRMz%u0`:o_F IDATx{pTǿnȋLdXZ`ci-3:B;(Έ"vJ;ꔶvDњV>R @(D=>D3sgwws~Z&!4h 1@_&!d!#4>@6f8`Pc͌]gΜٺnݺ $d,T('wu֭[W=!)q wgx`FqRUssww")5R9؊eje0 }(goj9sP,6;G1$oYdLP T2T3Oݣ@2h{W8'r'uEG;h0Pw*Yƀ B$+E[Czm$sL43 ,-{oIbf1|P۶# <|Z1cf+cǎɧOݻr9&nHl65?eeejfySܼA$>{>Ny@G=Rz"#xάh$(li(+#wzh/8>P + #{On + Ys0{;*RF!C FScIld R$VYHQTQIHc8u~ 7N:8rHA\\2 *F#8fiUd9)g-*ʵ[vN*R]^lVWIEET +*"a0E4JAU1 0$&?Z u-m۶Y/]Rz)gO.rFx"pgU_vJ/AI};sGASZ Ζ-[JV\Y-IVH &07:Ʉ\L)$3L&xzl<+L,oM0AN[[[[hѢY}c+։HAk^C ۈ%'_͓^3*f.5JqPR0_(Cx{l6j%{P (fCBLl! q{w8 ËXvLj>Zп#jD׀eO9TY`7}g ;7e@aշaBM<0Ο%P,#*e\Eތ}%@kxGy^ȂrX쩞N9gdv,y>|vхQ[xS@3YKPtDD5ս}Oxx)hGU); ߬JUWZ8sι٘9 ©M+ $Ɩ_z}3!t"Ik6jysϜ=ư۱g_҄H(u׼8 qR98E{.7}<~T`?4q@/ܤutf#&h2pe1UUU͛74w1'pc-))GCfO@b*sO"Rпv4,mӦME饥wJ$g}Q 4(I.]лtA_c>>%I?\~_{{^mmaÆx)#pCWϔ6m2̛7oO]]]QaGOX7O9czeee2}˜BoaPH51ǣɿEl-'w5k&M,Xʯ6v)9XjA5'j_RH|3ܴU5kC/W‚%FB@*Xai^u RIz $ˬдVN;i JISԩ=av+I*IRH`Zi7}H/I0کk񈟫#.xN9A%)޼ *I_z pSU 8Ѵ^jis!FGTMهP ҃ʶj 3|3yxNYF=dxp!tAQl"g'";?〤t",a9H5?!8i:e@} $ R1ժBbE 'M)'CŴkI[1ͭī#pR:e#d n vÓd&I 'uGL,YA.\t~aU $K,Ԁ*TNRV \PVYƿYAI&3դg:QruEтҚd>({6/jʲ[0ʦQF2'0Dp]Dp+Wk)@⢄V d ؉K'^ޙxh5P%u!Ȍh6L hdЭV@b!0MM{'2IfeJm(l'F ,>3{lI+蟳"#蠓9xRҳ6 J )&@@+Y: &H"HiK$+rPIENDB`objenesis-3.0.1/website/site/resources/objenesis.png000066400000000000000000000346461336222440400226200ustar00rootroot00000000000000PNG  IHDR1PrgAMA abKGDC oFFs(F pHYs  tIME 2 IDATx]w`n:, i"b!vEx`A"(MA)BQbB@B Bz6e1wv&!缷ݙs=\>a#վ@A_S+gIX7h1@_^(:vby (b؝/0%ê'&u'A BuE\ 2o ]E!L\\Ώ)!SCBy6[yk;c)s $ȲzbBv9t!IJ ɫ.ގbyP B (A(3R^w$%Q{f5P,rfofoš ! xyZ7eL?ȠBʰX,yv𕣔X,  󻉄PRX,K mub,Kltӏ,rHlᖛ< L]l&<:B\ Do]C<)pҶDE_ casiN2Esp#ƅ)F/QY$"%y{- y', cGN@p$H?SrF$~,SLAFxhF` ?Pr`|tbŪwp$i۳ čG~^@~()*OjН-IReUPbG [(U.eHX,wB32sbڴi?un8ZHJ(K%Ȑ by\]\N;}収GYK%y뷌i3[v|8TlJ䵷8v2F:>J@}dz:wp顿CupV] ~О_ 7<@2!?e i I P7P|C#l;/&jα Q':~e5]f+3#8MERJV~zO+?;W3}TJ~Px7 07zKh<|W;=/\LULH(([?R,ZXGwV/V `b6@7vRo6Ø<2lz0B ΖzSߑ)%.PJ@}Ke`gB\n9#JYVPE1l<V7_=wJRFyjc7'VQܴ}nMˬhNӨ"2Ve)g&tU ݡ}8]7$ҰEQ\i]rSX{ `5/UbKk.\ة/ڳaÆ6#U{ },Pa#H嶒\@no{E2˕?qĿ@n]Ѣe lٲP9 /9p3:B^G8l@('dš'Hg6syRNhLY&}`p4$[pN'XYfuFe ՐP 2Ƞ+ZuE1k $[,&j S@}1ZJ#ӥ%WH$N40: F=Ӗ7e9k7Gd2$GuL䖁1WE{eWvѽyENxws4lVÿEq܊(O]2/piWv)h46ޟsk\.Swcl9/R5֧:lڳGDQܨ7%>{Jil}%\KnwPCx<{(漶սB?f| պy(&͘%>\ M\J]C OV̢Ao־#u6]KˇȲ djځ^[4>ac?Z")T$@@V8Ͽt#wTKg0Ez/SMϐj2S?|?8O{LO]N(S~|^ɖ$i멛{>ܓ J-Vݹe?rsAA@&85wl`uEQܩisAOVVH}2~#R^Ӎs%A bg0=Byb-xҞM{0@Odn|#;cbyY[?w0.PYdឞP,xG e*|Aց?#t<-7Μܓ3 ~GB|73n3Coh!?%?=CyZhެyiwgLt隩A1u~"zAgZʃRL~&w?>uιğv6wsSJ쿇ʟ~JoN.-s$$n 9rdӺu#nٲ)ℱ_L,11Ѧ9C{1FuWGy:a;^vZPP;]$׉P Jz2k \CAǂ啅ꓡw\}us% 'sllAO3OMyM%=r.(&eQ<;BW-nQW*X,ubYpAg)kPBT޽;~z'T>N\wCs.Z-j9'#9"#=QI wΏnsM 8($bU3ط7=bcc sҩY!}2A8@V, YBe&(n$ՙ%&gEcn7UrЅ3qY@Nz[Q{p&f<Xt9YVv:&xf&0pn?7ULt$򋛉{pejөiyV]ݮxAdA7U#Q"ؼJjz@h1 )0?NA|yZ1 J(ΤV8dP4?,vz~ B<3D#P3KAEưQmbRSAw1YzG)(>lF<-OX.MBqT&?1n9k:^Ð Z&7+ҒO|@^{9ՠDQDnY{ sH!BL($&"s_ŏ,Y_<`uJaq9\9-橯B.qʐDQ7/}﯀ɔeg'7OEqޜYX*!0\sڌ5!^Q}BI;vKݻ-iyMiD9E(-㟜n\rB]`1i,q_'/+V}LjaX:Yi7aĝ}A{A٨,΁*˙o@繋!/|w7#o(Ӗ/(D4ީ.}(Y! RTT[̡C'jz!.(nk"sV6c漧6*i2VͯEsmTRk^eBt(EYda_w<*ƥC9dU N}'ჺքO'"nery:Zˁ^ @q8 cˎvcwdPj@q'܌D@~A .Ћg?(lLKWyE{ @R 0Vڨz^̤]?iԠOǂX-.V cx,@c QW-Jmzȱ2F1r҆POVNF,p>QJ2藹A#  ⯟,EwB&b7_yls~f¿ߢO4)r"Wu *f;zNkVP(\\ By$eU>:BuGT3LHBU=3s˙1 |\TdddHO>SDQj>e Lf䅅x x1|/sVk^(fwM  QSI;PAE ٰaC ].c2(G. sq\eee 'M^wVKr4\fMTe0Hx3Ȥ"*+ B#)hs^$݆yMyyIPz=fϬ\3kO7|^婃N)ŬYBLO۶0oDnTe_>c~]zvX&2&]bjIDbo(~n me7é,[UE.:Y:҄F';5BUF; 2 2 2 2 ѷ7D-E)=;6B`vB9XZ+v^Æ; :9uO)lS0E^9G!8P[MEN9`b:VPY3 39XX{Nx6C!0eA.%@Vc_[iЕ`KoY3MxS!Phxiun?xN$M7rW"K}#f!U,E?۔ڠI8f@w(~VC4/jIu+4jFa_-˙g{։hЀbуx^DX"眐NHLݝͷH_}>?0 4Rcfqߟ3IZ%,Y)቟ٲ*w9yIyV`nZ{dq,u =4$G@yrJ=vc>?^`]3ĉB Qaӯ_'N+B ˬ_4իW̙3GEQf"S^uQaa~E_HD>r,ΗHѲ˟:<q`̅I&54h;vl2B|^^hxjAWLLLRs<(</Vb>pN73ȶ{n ~c4LLr;-W& Pn1L{w6.!qn 9 7j#$> w7eNVeyHIRPgitZ]sHv&%C̞:stJEeYIct VJr:*+BkR%=lǠ zӣ?o4>;/BLp\̶ĆajJ;E{?EqˮU}\`KW|Dȱ;:kKvWfIoQU_PJ߄}i/ͮ}_&C9 ^OE/#{T &*@iڬj lB22KA%:͠d{ ,URu _yx|q@ Y%糒R'+ PX/Ƅ2:-xaDqʲ\__ ԥx^ N2G>fh6`gD;&e}AAgՠ'xbzyB97bU bKILN{8/`;D9b^܅B<0FE-XX FY?jj&ZX(.DZyYɿΘ) yѱc637 z yfAcLfY(%]@(~ vt͘2J;T?[5^.-hܛ69#?4$Q\\G@ cMB!'rYz>(n[)pб\M*C&dxnK7~*sq19 ;0UĬW.7`hVLNY֎sOo.bK([@ٷ,h|$KW)%˴vjZ[aM-sJ X,s!6^u~<;A Vزa.Of s]X}\/Ew?GxzKWOd%|#A9']/٣+wCOF*D3K5/C+93(=tdLM;0JH>PyE>tW3.-pz~Q bhz#ЩwA[]@l ^췦\k)ZS«1 PG-EFFVJHTw֭vm-TÇӸqQP^^$IY<5Ad"5 ^5b0^:a53P#pF#i|5YϞ=o^`Su) QC` +#;?o=z&T/Y$''̛7yۛxd6v :@W/<BiiV\RJ)9e%e ⤎Md2O}h5=U^Ռ"sQ@x_y&Nx/:eXRt{{wD*a<)5Y+[4 ^ւzW%\Vkyl̿iC}cp3Xll >jg1ZU0WI:)U٢"O@/9mVfˀFcSjXAPKW^em-";AjEza w_TP;G=$jnK]8m[ke[b}S~+<; [纈^_gY&+5[Uȟ;[O>mjFg_ɸq㾳>[eYvvmk!4{. %{iXhԅ@N@MJޞӿ3sX@-i:gDhz*m*:'@p0U&fŽJLa~5B %loe, @ v8qW՘jS>pXY; +3B hŶr; NVGu P.)cj*X2Y.L@w1[Nتu*Bf k *gh?j#de|RCut]L6Zmrf+e>8u-Є]Q4~^}͘h$p[t62F˘*=+zyVw"~QM` Uo`AQeV@F_jj>Z6t<ѝ64VW5pmfu j.E͢mVoL!j!/H9z\}O"-/C[&__A^ 68jAdAdAdAdAdAdAdIQ'7dB(FN!Xz{O=I5Pd br~zW}3'Nx6 "\d]מ=73͡ A'e Z7=0*,$APA93|iHcted\ (!BUϔ3P+ 2Jj.ڢ$nݺԾ}{Ә1cW-^}BBٰaCvIII]((!& =cA E(A'BA @ 6#~QNm\0oT6A=??d2U" @3Ƞ?.'H.T$QE%s(EX8!a&P]d锩.^)…HOPv]7l1S/+ٽT 2@C2q²‹e%ܬsYI9?v_.B&nsnapeHNN'E@dR&l6!4T@X{v*9<ܹsv]FZri]͓/AØ.!d:R7 CvQhѲD , rMX|Vzb LrB[٪uM@ѫW/wzLV B(hU]/TcdAALū|`/YK5CQftvIHL**$fU";'8_~10w S k` ٫We)h Zo;(zz%GfA7E1ʭ.).p`5o KpM}`-q"i)V$آU),y0jh ʢ_~[$+X4lcz^*&(viJݱ(f0Z-Q]NuEۢš~k//?pОp}ȄxȞ:7j]Wχ uRM4%1Bc&inOv-ͽ.\PxFQ;CnN()v *(7iJm `D#搩#}o|F6SQUBr":_Cg6x_f0iwo[ S0T`]_;-[w~%7|rpIȄpZ;o| JwavC_W_-oe(++,uF4W˛2-Ȳi`V5JJfֹqp7֪8V_?wa1 sVRbcc7όumeas` }m C&J_G?}K 96d .ݮngҊ}L=e%]pr59f ,M]i+«\%K&)W7Ag Pb[L&M>ybL x)0@e; P@ 0KYרG*cIA2OI5dS-$ytJIap+:Q51l!0;•6*p:-UA[>m}z ׯАy98. S EJTQhX+ gd.z I'D&3kH`.$v[RR|Sl ;0d$ΧPƁ3*) Nɡ3r \RVӡkV xngT S@_w8ĭd&'AJae]G7^Bgj6[머M-e&-Mxv+v+w[,}5@K@@ \~Q=sR4bi& ϭvG7G7΅)hQ߼L6b*0V],dMcajGPh0GQgf϶.R0(wRw:iAv (((%P\EUYBCBBfi6fY2L.DFxb<҄,t2fYͫZG=z<Ǘ4L  !&TC%+ DASOd"{極qԉBM)qeT& FBd"_TBbx,l ھ/x#` 6s RIay ?j-/pQO Fgm U(SLE Dtk{hOW@ ֳeNKͷui?}`Ϛ.Z#E6泮QY+ l{A]WAMYHSڷϘ~h"d7С?LYoBc;ie?j=bj H HG|0KhGZsCr9Z,3jVmUxiʏ;*ǢzU3u;[}rH-؇ǔkвv: üDScĕt̰\Pg<zu`Вxnayrڜj (. B(֮Ƭf# nMp덣NU%H>"}kvVq Ȼ) 4l֑71UWϵ =UM1]Bˤ:ejLNAncOdMnb_6 r.hJ=x%XDHNIJAdAdAdAW;&2IENDB`objenesis-3.0.1/website/site/resources/robots.txt000066400000000000000000000000161336222440400221620ustar00rootroot00000000000000User-agent: * objenesis-3.0.1/website/site/resources/style.css000066400000000000000000000137161336222440400217760ustar00rootroot00000000000000/** * Copyright 2006-2018 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. */ /*--------------------------------------------------------------------------- * Two- and three-column layout */ #banner { top: 0; left: 0; right: 0; height: 90px; } #left { position: absolute; z-index: 2; left: 8px; width: 184px; top: 100px; bottom: 8px; margin: 0; padding: 0; } #right { position: absolute; z-index: 1; right: 8px; width: 184px; top: 100px; bottom: 8px; margin: 0; padding: 0; } .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: 0; border: none; padding-bottom: 8px; } /*--------------------------------------------------------------------------- * Default element styles */ body { padding: 0; margin: 0; border: 0; font-family: helvetica, arial, sans-serif; font-size: 12px; background-color: white; color: black; } h1, h2, h3, h4, h5, h6 { margin: 0; border: 0; padding: 0; 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: 0; } img { border: 0; padding: 0; margin: 0; } p { border: 0; padding: 0; margin: 0 0 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: 0; padding: 0; margin-top: 0; margin-bottom: 12px; margin-left: 20px; } /*--------------------------------------------------------------------------- * Page banner */ #banner { margin: 0; border: 0; border-bottom: 1px solid #c8f; padding: 0; 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: 0; top: 0; margin: 8px; font-weight: normal; } /*--------------------------------------------------------------------------- * Page content */ #content { margin: 0; background-color: white; color: black; height: 100%; } #content h1 { width: 100%; font-size: 18px; background-color: #6e61ad; color: white; padding: 2px 2px 2px 6px; margin-top: 24px; margin-bottom: 12px; } #content .FirstChild { /* IE doesn't understand first-child pseudoelement */ margin-top: 0; } #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: 0; font-size: 11px; } .SidePanel h1 { margin: 0; border: 0; 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: 0; 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: 0; padding: 0; } .NewsText { padding: 0; margin: 0; 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; } objenesis-3.0.1/website/site/templates/000077500000000000000000000000001336222440400201005ustar00rootroot00000000000000objenesis-3.0.1/website/site/templates/skin.html000066400000000000000000000050301336222440400217300ustar00rootroot00000000000000 Objenesis : \${title} \${head}

\${title}

\${body}

<#list sitemap.sections as section>