First drop

This commit is contained in:
Andy Clement
2012-12-07 08:43:54 -08:00
parent deff1cc219
commit 1bf580f54b
996 changed files with 61618 additions and 3 deletions

7
.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
target/
bin/
subbin/
builds/
superbin/
springloaded-*.jar
.DS_Store

View File

@@ -1,4 +1,86 @@
spring-loaded
=============
# Welcome to Spring-Loaded
Java agent that enables class reloading in a running JVM
## What is Spring Loaded?
Spring Loaded is a JVM agent for reloading class file changes whilst a JVM is running. It transforms
classes at loadtime to make them amenable to later reloading. Unlike 'hot code replace' which only allows
simple changes once a JVM is running (e.g. changes to method bodies), Spring Loaded allows you
to add/modify/delete methods/fields/constructors. The annotations on types/methods/fields/constructors
can also be modified and it is possible to add/remove/change values in enum types.
Spring Loaded is usable on any bytecode that may run on a JVM, and is actually the reloading system
used in Grails 2.
# Installation
A dev build of version 1.1.1 is available [here](https://github.com/downloads/SpringSource/spring-loaded/springloaded-1.1.1-dev.jar). The download is the agent jar and needs no further unpacking before use.
# Running with reloading
java -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify SomeJavaClass
The verifier is being turned off because some of the bytecode rewriting stretches the meaning of
some of the bytecodes - in ways the JVM doesn't mind but the verifier doesn't like. Once up and
running what effectively happens is that any classes loaded from jar files (dependencies) are not
treated as reloadable, whilst anything loaded from .class files on disk is made reloadable. Once
loaded the .class file will be watched (once a second) and should a new version appear
SpringLoaded will pick it up. Any live instances of that class will immediately see the new form
of the object, the instances do not need to be discarded and recreated.
No doubt that raises a lot of questions and hopefully a proper FAQ will appear here shortly! But in
the meantime, here are some basic Qs and As:
Q. Does it reload anything that might change in a class file?
A. No, you can't change the hierarchy of a type. Also there are certain constructor patterns of
usage it can't actually handle right now.
Q. With objects changing shape, what happens with respect to reflection?
A. Reflection results change over time as the objects are reloaded. For example, modifying a class
with a new method and calling getDeclaredMethods() after reloading has occurred will mean you see
the new method in the results. *But* this does mean if you have existing caches in your system
that stash reflective information assuming it never changes, those will need to be cleared
after a reload.
Q. How do I know when a reload has occurred so I can clear my state?
A. You can write a plugin that is called when reloads occur and you can then take the appropriate
action. Create an implementation of `ReloadEventProcessorPlugin` and then register it via
`SpringLoadedPreProcessor.registerGlobalPlugin(plugin)`. (There are other ways to register plugins,
which will hopefully get some documentation!)
Q. What's the state of the codebase?
A. The technology is successfully being used by Grails for reloading. It does need some performance
work and a few smacks with a refactoring hammer. It needs upgrading here and there to tolerate
the invokedynamic instruction and associated new constant pool entries that arrived in Java 7.
It could also use a proper (gradle probably) build process.
# Working with the code
git clone https://github.com/SpringSource/spring-loaded
Once cloned there will be three projects suitable for import into eclipse. The main project and
two containing testdata. One of the test projects is an AspectJ project (containing both Java
and AspectJ code), the other test project is a Groovy project. To compile these test projects
in Eclipse you will need the relevant eclipse plugins:
AJDT: update site: `http://download.eclipse.org/tools/ajdt/42/dev/update`
Groovy-Eclipse: update site: `http://dist.springsource.org/snapshot/GRECLIPSE/e4.2/`
After importing them you can run the tests. There are two kinds of tests, hand crafted and
generated. Running all the tests including the generated ones can take a while.
To run just the hand crafted ones change `GlobalConfiguration.generatedTestsOn=false`. To run the
tests create a Run Configuration of type JUnit for the project org.springsource.loaded and on the
arguments tab set `VM arguments` to `-noverify` - then click run.
To build a new version of the agent jar, just run `ant` in the org.springsource.loaded project,
this will create a new springloaded-dev.jar in the builds folder using the compiled eclipse
output. Note: the jarjar task is used to repackage asm with a prefix (to avoid clashes) -
so you will need to install the jarjar task (from the project lib folder) into your ant lib folder.
# Can I contribute?
Sure! Just press *Fork* at the top of this github page and get coding. Before we accept pull
requests we just need you to sign a simple contributor's agreement - which you can find
[here](https://support.springsource.com/spring_committer_signup). Signing the contributor's
agreement does not grant anyone commit rights to the main repository, but it does mean that we
can accept your contributions, and you will get an author credit if we do. Active contributors
might be asked to join the core team, and given the ability to merge pull requests.

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
<classpathentry kind="lib" path="groovy-1.8.2.jar" sourcepath="groovy-src-1.7.8.zip"/>
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springsource.loaded.testdata.groovy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,12 @@
#Fri Dec 03 07:39:45 PST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
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.source=1.6

View File

@@ -0,0 +1,2 @@
eclipse.preferences.version=1
groovy.compiler.level=20

View File

@@ -0,0 +1,55 @@
#Tue Dec 07 13:19:07 PST 2010
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=false
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=false
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=true
sp_cleanup.correct_indentation=true
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
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=true
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=true
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=true
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

View File

@@ -0,0 +1,351 @@
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.
=======================================================================
Spring Loaded 1.1.0:
Spring Loaded 1.1.0 includes a number of subcomponents with
separate copyright notices and license terms. The product that
includes this file does not necessarily use all the open source
subcomponents referred to below. Your use of the source
code for the these subcomponents is subject to the terms and
conditions of the following licenses.
SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
>>> asm - 3.2
>>> asm-commons - 3.2
>>> asm-tree - 3.2
>>> asm-util - 3.2
-------------SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES------------------------------
BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES are applicable to the following component(s)
>>> asm - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2007 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-commons - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-tree - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-util - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
[SPRINGLOADED110KL072612]

View File

@@ -0,0 +1,27 @@
package clinitg;
public class Four {
static {
System.out.println("original clinit");
bar()
}
public static String run() {
bar()
boo()
baz()
}
public static void bar() {
print '1'
}
public static void boo() {
print '2'
}
public static void baz() {
print '3'
}
}

View File

@@ -0,0 +1,37 @@
package clinitg;
public class Four2 {
public static void biz() {
print '1'
}
static {
bar()
FourHelper.doo()
}
public static String run() {
bar()
baz()
biz()
boo()
}
public static void bar() {
print '1'
}
public static void baz() {
print '3'
}
public static void boo() {
print '2'
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class FourHelper {
public static void doo() {
print 'a'
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class One {
public static int i = 5;
public static String run() {
return Integer.toString(i);
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class One2 {
public static int i = 7;
public static String run() {
return Integer.toString(i);
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class Three {
// i have no clinit
public static String run() {
return "1";
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class Three2 {
// still no clinit
public static String run() {
return "1";
}
}

View File

@@ -0,0 +1,13 @@
package clinitg;
public class Three3 {
static int i;
{
i = 4;
}
public static String run() {
return Integer.toString(i);
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class Two {
public final static int i = 55;
public static String run() {
return Integer.toString(i);
}
}

View File

@@ -0,0 +1,10 @@
package clinitg;
public class Two2 {
public final static int i = 99;
public static String run() {
return Integer.toString(i);
}
}

View File

@@ -0,0 +1,117 @@
package controller
class Controller {
def index = {
run(action: "list", params: "2")
}
public void printSomethingRandom() {
System.out.println("abcde")
}
public void run(Map m) {
System.out.println(m);
}
public static void main(String[] args) {
new Controller().index() // prints [action:list, params:2]
}
public void execute() {
new Controller().index() // prints [action:list, params:2]
}
// def list = {
// params.max = Math.min(params.max ? params.int('max') : 10, 100)
// [testInstanceList: Test.list(params), testInstanceTotal: Test.count()]
// }
//
// def create = {
// def testInstance = new Test()
// testInstance.properties = params
// return [testInstance: testInstance]
// }
//
// def save = {
// def testInstance = new Test(params)
// if (testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.created.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "create", model: [testInstance: testInstance])
// }
// }
//
// def show = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// [testInstance: testInstance]
// }
// }
//
// def edit = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// return [testInstance: testInstance]
// }
// }
//
// def update = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// if (params.version) {
// def version = params.version.toLong()
// if (testInstance.version > version) {
//
// testInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'test.label', default: 'Test')] as Object[], "Another user has updated this Test while you were editing")
// render(view: "edit", model: [testInstance: testInstance])
// return
// }
// }
// testInstance.properties = params
// if (!testInstance.hasErrors() && testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.updated.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "edit", model: [testInstance: testInstance])
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
//
// def delete = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// try {
// testInstance.delete(flush: true)
// flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// catch (org.springframework.dao.DataIntegrityViolationException e) {
// flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "show", id: params.id)
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
// }
}

View File

@@ -0,0 +1,117 @@
package controller
class Controller2 {
def index = {
run(action: "custard", params: "345")
}
public void printSomethingRandom() {
System.out.println("abcde")
}
public void run(Map m) {
System.out.println(m);
}
public static void main(String[] args) {
new Controller2().index() // prints [action:list, params:2]
}
public void execute() {
new Controller2().index() // prints [action:list, params:2]
}
// def list = {
// params.max = Math.min(params.max ? params.int('max') : 10, 100)
// [testInstanceList: Test.list(params), testInstanceTotal: Test.count()]
// }
//
// def create = {
// def testInstance = new Test()
// testInstance.properties = params
// return [testInstance: testInstance]
// }
//
// def save = {
// def testInstance = new Test(params)
// if (testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.created.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "create", model: [testInstance: testInstance])
// }
// }
//
// def show = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// [testInstance: testInstance]
// }
// }
//
// def edit = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// return [testInstance: testInstance]
// }
// }
//
// def update = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// if (params.version) {
// def version = params.version.toLong()
// if (testInstance.version > version) {
//
// testInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'test.label', default: 'Test')] as Object[], "Another user has updated this Test while you were editing")
// render(view: "edit", model: [testInstance: testInstance])
// return
// }
// }
// testInstance.properties = params
// if (!testInstance.hasErrors() && testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.updated.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "edit", model: [testInstance: testInstance])
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
//
// def delete = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// try {
// testInstance.delete(flush: true)
// flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// catch (org.springframework.dao.DataIntegrityViolationException e) {
// flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "show", id: params.id)
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
// }
}

View File

@@ -0,0 +1,122 @@
package controller
class Controller3 {
def preIndex = {
printSomethingRandom()
}
def index = {
run(action: "custard", params: "345")
}
public void printSomethingRandom() {
System.out.println("abcde")
}
public void run(Map m) {
System.out.println(m)
}
public static void main(String[] args) {
new Controller3().index() // prints [action:list, params:2]
}
public void execute() {
new Controller3().index() // prints [action:list, params:2]
}
// def list = {
// params.max = Math.min(params.max ? params.int('max') : 10, 100)
// [testInstanceList: Test.list(params), testInstanceTotal: Test.count()]
// }
//
// def create = {
// def testInstance = new Test()
// testInstance.properties = params
// return [testInstance: testInstance]
// }
//
// def save = {
// def testInstance = new Test(params)
// if (testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.created.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "create", model: [testInstance: testInstance])
// }
// }
//
// def show = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// [testInstance: testInstance]
// }
// }
//
// def edit = {
// def testInstance = Test.get(params.id)
// if (!testInstance) {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// else {
// return [testInstance: testInstance]
// }
// }
//
// def update = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// if (params.version) {
// def version = params.version.toLong()
// if (testInstance.version > version) {
//
// testInstance.errors.rejectValue("version", "default.optimistic.locking.failure", [message(code: 'test.label', default: 'Test')] as Object[], "Another user has updated this Test while you were editing")
// render(view: "edit", model: [testInstance: testInstance])
// return
// }
// }
// testInstance.properties = params
// if (!testInstance.hasErrors() && testInstance.save(flush: true)) {
// flash.message = "${message(code: 'default.updated.message', args: [message(code: 'test.label', default: 'Test'), testInstance.id])}"
// redirect(action: "show", id: testInstance.id)
// }
// else {
// render(view: "edit", model: [testInstance: testInstance])
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
//
// def delete = {
// def testInstance = Test.get(params.id)
// if (testInstance) {
// try {
// testInstance.delete(flush: true)
// flash.message = "${message(code: 'default.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// catch (org.springframework.dao.DataIntegrityViolationException e) {
// flash.message = "${message(code: 'default.not.deleted.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "show", id: params.id)
// }
// }
// else {
// flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'test.label', default: 'Test'), params.id])}"
// redirect(action: "list")
// }
// }
// }
}

View File

@@ -0,0 +1,7 @@
package enums
interface ExtensibleEnum {
int getIntValue()
}

View File

@@ -0,0 +1,7 @@
package enums
interface ExtensibleEnum3 {
int getValue()
}

View File

@@ -0,0 +1,7 @@
package enums
interface ExtensibleEnumB {
int getIntValue()
}

View File

@@ -0,0 +1,24 @@
package enums;
public class RunnerA {
public static void main(String[] args) {
run();
}
public static void run() {
System.out.println(WhatAnEnum.RED);
System.out.println(WhatAnEnum.GREEN);
System.out.println(WhatAnEnum.BLUE);
WhatAnEnum[] vals = WhatAnEnum.values();
System.out.print("[");
for (int i = 0; i < vals.length; i++) {
if (i > 0) {
System.out.print(" ");
}
System.out.print(vals[i]==null?"NULL":vals[i].toString());//+" "+vals[i].getIntValue());
}
System.out.println("]");
System.out.println("value count = " + vals.length);
}
}

View File

@@ -0,0 +1,24 @@
package enums;
public class RunnerB {
public static void main(String[] args) {
run();
}
public static void run() {
System.out.println(WhatAnEnumB.HAVING_A_NICE_TIME);
System.out.println(WhatAnEnumB.JUMPING_INTO_A_HOOP);
System.out.println(WhatAnEnumB.LIVING_ON_A_LOG);
WhatAnEnumB[] vals = WhatAnEnumB.values();
System.out.print("[");
for (int i = 0; i < vals.length; i++) {
if (i > 0) {
System.out.print(" ");
}
System.out.print(vals[i]+" "+vals[i].getIntValue());
}
System.out.println("]");
System.out.println("value count = " + vals.length);
}
}

View File

@@ -0,0 +1,29 @@
package enums
enum WhatAnEnum {//implements ExtensibleEnum {
RED,//(1),
GREEN,//(2),
BLUE//(3),
// private WhatAnEnum(String s, int i) {
// super(s,i);
// print ">>"+s+" "+i
// }
// LIVING_ON_A_LOG,//(4),
// WHAT_DID_YOU_DO,//(5),
// UNKNOWN//(0)
// final int intValue
// private WhatAnEnum(int intValue) {
// this.intValue = intValue
// }
//
// private static final Map<Integer, WhatAnEnum> MAP = [:] as Map<Integer, WhatAnEnum>
// static {
// WhatAnEnum.values().each { WhatAnEnum response ->
// MAP.put(response.intValue, response)
// }
// }
}

View File

@@ -0,0 +1,33 @@
package enums
enum WhatAnEnum2 { // implements ExtensibleEnum {
RED,GREEN,BLUE,YELLOW;
// private WhatAnEnum2(String s, int i) {
// super(s,i);
// print ">>"+s+" "+i
// }
// PETS_AT_THE_DISCO,//(1),
// JUMPING_INTO_A_HOOP,//(2),
// HAVING_A_NICE_TIME,//(3),
// LIVING_ON_A_LOG,//(4),
// WHAT_DID_YOU_DO,//(5),
// WOBBLE,//(6),
// UNKNOWN//(0)
// final int intValue
//
// private WhatAnEnum2(int intValue) {
// this.intValue = intValue
// }
//
// private static final Map<Integer, WhatAnEnum2> MAP = [:] as Map<Integer, WhatAnEnum2>
//
// static {
// WhatAnEnum2.values().each { WhatAnEnum2 response ->
// MAP.put(response.intValue, response)
// }
// }
}

View File

@@ -0,0 +1,26 @@
package enums
enum WhatAnEnum3 implements ExtensibleEnum3 {
PETS_AT_THE_DISCO(1),
JUMPING_INTO_A_HOOP(2),
HAVING_A_NICE_TIME(3),
LIVING_ON_A_LOG(4),
WHAT_DID_YOU_DO(5),
WOBBLE(6),
UNKNOWN(0)
final int value
private WhatAnEnum3(int intValue) {
this.value = intValue
}
private static final Map<Integer, WhatAnEnum3> MAP = [:] as Map<Integer, WhatAnEnum3>
static {
WhatAnEnum3.values().each { WhatAnEnum3 response ->
MAP.put(response.value, response)
}
}
}

View File

@@ -0,0 +1,23 @@
package enums
enum WhatAnEnumB implements ExtensibleEnumB {
PETS_AT_THE_DISCO(1),
JUMPING_INTO_A_HOOP(2),
HAVING_A_NICE_TIME(3),
LIVING_ON_A_LOG(4),
WHAT_DID_YOU_DO(5),
UNKNOWN(0)
final int intValue
private WhatAnEnumB(int intValue) {
this.intValue = intValue
}
private static final Map<Integer, WhatAnEnumB> MAP = [:] as Map<Integer, WhatAnEnumB>
static {
WhatAnEnumB.values().each { WhatAnEnumB response ->
MAP.put(response.intValue, response)
}
}
}

View File

@@ -0,0 +1,26 @@
package enums
enum WhatAnEnumB2 implements ExtensibleEnumB {
PETS_AT_THE_DISCO(1),
JUMPING_INTO_A_HOOP(2),
HAVING_A_NICE_TIME(3),
LIVING_ON_A_LOG(4),
WHAT_DID_YOU_DO(5),
WOBBLE(6),
UNKNOWN(0)
final int intValue
private WhatAnEnumB2(int intValue) {
this.intValue = intValue
}
private static final Map<Integer, WhatAnEnumB2> MAP = [:] as Map<Integer, WhatAnEnumB2>
static {
WhatAnEnumB2.values().each { WhatAnEnumB2 response ->
MAP.put(response.intValue, response)
}
}
}

View File

@@ -0,0 +1,6 @@
package simple
class Back {
int var = 35
}

View File

@@ -0,0 +1,9 @@
package simple
class Back2 {
int var = 35
int var2= 3355
}

View File

@@ -0,0 +1,7 @@
package simple
class Basic {
public String run() {
return 'hello'
}
}

View File

@@ -0,0 +1,8 @@
package simple
class Basic2 {
public String run() {
return 'goodbye'
}
}

View File

@@ -0,0 +1,11 @@
package simple
class Basic3 {
public String run() {
return getString();
}
public String getString() {
return 'abc'
}
}

View File

@@ -0,0 +1,7 @@
package simple
class Basic4 implements Serializable {
public String run() {
return 'hello'
}
}

View File

@@ -0,0 +1,11 @@
package simple
class BasicB {
public static String run() {
return getString();
}
public static String getString() {
return "hello"
}
}

View File

@@ -0,0 +1,15 @@
package simple
class BasicB2 {
public static String run() {
return getOtherString();
}
public static String getString() {
return "hello"
}
public static String getOtherString() {
return "goodbye"
}
}

View File

@@ -0,0 +1,11 @@
package simple
class BasicC {
public String run() {
return getString();
}
public String getString() {
return "hello"
}
}

View File

@@ -0,0 +1,15 @@
package simple
class BasicC2 {
public String run() {
return getOtherString();
}
public String getString() {
return "hello"
}
public String getOtherString() {
return "goodbye"
}
}

View File

@@ -0,0 +1,9 @@
package simple
class BasicD {
public String run() {
return 'hello'
}
}

View File

@@ -0,0 +1,9 @@
package simple
class BasicD2 {
public String run() {
return BasicDTarget2.getString()
}
}

View File

@@ -0,0 +1,7 @@
package simple
class BasicDTarget {
}

View File

@@ -0,0 +1,7 @@
package simple
class BasicDTarget2 {
static String getString() { return 'abc' }
}

View File

@@ -0,0 +1,12 @@
package simple
class BasicE {
public String run() {
// BasicETarget t = new BasicETarget()
// return t.getString()
return 'hello'
}
}

View File

@@ -0,0 +1,10 @@
package simple
class BasicE2 {
public String run() {
BasicETarget t = new BasicETarget()
return t.getString()
}
}

View File

@@ -0,0 +1,5 @@
package simple
class BasicETarget {
}

View File

@@ -0,0 +1,7 @@
package simple
class BasicETarget2 {
String getString() { return 'foobar' }
}

View File

@@ -0,0 +1,10 @@
package simple
class BasicF {
public String run() {
BasicFTarget t = new BasicFTarget()
return t.getString()
}
}

View File

@@ -0,0 +1,8 @@
package simple
class BasicFTarget {
int d= 4456;
public String getString() {
return '123'
}
}

View File

@@ -0,0 +1,5 @@
package simple
class BasicFTarget2 {
}

View File

@@ -0,0 +1,9 @@
package simple
class BasicFTarget4 {
int d = 4456;
int getString() {
return d
}
}

View File

@@ -0,0 +1,9 @@
package simple
class BasicG {
public String run() {
return BasicGTarget.foo()
}
}

View File

@@ -0,0 +1,5 @@
package simple
class BasicGTarget {
}

View File

@@ -0,0 +1,7 @@
package simple
class BasicGTarget2 {
static String foo() { return 'hw' }
}

View File

@@ -0,0 +1,25 @@
package simple
class BasicH {
public String run() {
// warmup
for (int i=0;i<100000;i++) {
m();
}
// measure
long l = System.currentTimeMillis()
for (int i=0;i<1000000;i++) {
m();
}
return Long.toString(System.currentTimeMillis()-l);
}
public void m() {
}
public static void main(String[] args) {
println new BasicH().run();
}
}

View File

@@ -0,0 +1,17 @@
package simple
class BasicWithClosure {
def clos =null;
public String run() {
clos = { println "hello!" }
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosure().run();
}
}

View File

@@ -0,0 +1,17 @@
package simple
class BasicWithClosure2 {
def clos = null;
public String run() {
clos = { println "hello!" }
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosure2().run();
}
}

View File

@@ -0,0 +1,17 @@
package simple
class BasicWithClosure3 {
def clos = null;
public String run() {
clos = { println "goodbye!" }
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosure3().run();
}
}

View File

@@ -0,0 +1,16 @@
package simple
class BasicWithClosureB {
def clos = { println "hello!" }
public String run() {
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosureB().run();
}
}

View File

@@ -0,0 +1,16 @@
package simple
class BasicWithClosureB2 {
def clos = { println "hello!" }
public String run() {
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosureB2().run();
}
}

View File

@@ -0,0 +1,16 @@
package simple
class BasicWithClosureB3 {
def clos = { println "goodbye!" }
public String run() {
print "Executing:"
clos()
}
public static void main(String[] args) {
new BasicWithClosureB3().run();
}
}

View File

@@ -0,0 +1,31 @@
package simple
class BasicWithClosureC {
public static void main(String[] args) {
new BasicWithClosureC().run();
}
public String run() {
foo()
doit {
doitInner {
println 'in closure'
}
}
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,31 @@
package simple
class BasicWithClosureC2 {
public static void main(String[] args) {
new BasicWithClosureC2().run();
}
public String run() {
doit {
doitInner {
println 'in closure'
foo() // moved from top of run() method to here
}
}
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,38 @@
package simple
class BasicWithClosureD {
public static void main(String[] args) {
new BasicWithClosureD().run();
}
public void xxx() {
}
public String run() {
foo()
String sone = "abc"
String stwo = "def"
// doit {
doitInner {
println 'string is '+sone
print "owner is "+(getOwner()==null?"null":"not null")
}
// }
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,34 @@
package simple
class BasicWithClosureD2 {
public static void main(String[] args) {
new BasicWithClosureD2().run();
}
public String run() {
foo()
String sone = "abc"
String stwo = "def"
// doit {
doitInner {
println 'string is '+stwo
print "owner is "+(getOwner()==null?"null":"not null")
}
// }
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,38 @@
package simple
class BasicWithClosureE {
public static void main(String[] args) {
new BasicWithClosureE().run();
}
public void xxx() {
}
public String run() {
foo()
String sone = "abc"
String stwo = "def"
// doit {
doitInner {
println 'string is '+sone
print "owner is "+(getOwner()==null?"null":"not null")
}
// }
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,38 @@
package simple
class BasicWithClosureE2 {
public static void main(String[] args) {
new BasicWithClosureE2().run();
}
public void xxx() {
}
public String run() {
foo()
String sone = "abc"
String stwo = "def"
// doit {
doitInner {
println 'string is '+sone+" "+stwo
print "owner is "+(getOwner()==null?"null":"not null")
}
// }
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,38 @@
package simple
class BasicWithClosureE3 {
public static void main(String[] args) {
new BasicWithClosureE3().run();
}
public void xxx() {
}
public String run() {
foo()
String sone = "xyz"
String stwo = "def"
// doit {
doitInner {
println 'string is '+sone
print "owner is "+(getOwner()==null?"null":"not null")
}
// }
}
public void doit(Closure c) {
c.call()
}
public void doitInner(Closure c) {
c.call()
}
public void foo() {
println 'foo() running'
}
}

View File

@@ -0,0 +1,7 @@
package simple
class CopyOfBasicD {
public String run() {
}
}

View File

@@ -0,0 +1,13 @@
package simple
class Front {
Back b = new Back()
public Object run() {
return b.var
}
public Object run2() {
return b.var2
}
}

View File

@@ -0,0 +1,14 @@
package simple
class LFront {
public Object run() {
String x = "abc";
return x;
}
public Object run2() {
int i = 99;
return i;
}
}

View File

@@ -0,0 +1,14 @@
package simple
class LFront2 {
public Object run() {
String x = "xxx";
return x;
}
public Object run2() {
int i = 88;
return i;
}
}

View File

@@ -0,0 +1,30 @@
package simple
import java.lang.reflect.Field;
class SelfReflector {
public static void main(String[] args) {
println run();
}
public int i
public static String run() {
StringBuilder s = new StringBuilder()
Field[] fs = getFields()
List<String> names = new ArrayList<String>()
for (Field f: fs) {
names.add(f.getName());
}
Collections.sort(names);
s.append(names.size()).append(" ");
for (String n: names) {
s.append(n).append(" ");
}
return s.toString().trim();
}
public static Field[] getFields() {
return SelfReflector.class.getDeclaredFields();
}
}

View File

@@ -0,0 +1,9 @@
package simple
class Values {
public Integer run() {
return 123
}
}

View File

@@ -0,0 +1,9 @@
package simple
class Values2 {
public Integer run() {
return 456
}
}

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="cglibsrc"/>
<classpathentry kind="src" path="pluginsrc"/>
<classpathentry kind="src" output="superbin" path="supersrc"/>
<classpathentry kind="src" output="subbin" path="subsrc"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/org.springsource.loaded"/>
<classpathentry kind="lib" path="lib/cglib-nodep-2.2.jar" sourcepath="lib/cglib-nodep-2.2-sources.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.springsource.loaded.testdata</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,12 @@
#Mon Feb 08 11:33:02 PST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
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.source=1.6

View File

@@ -0,0 +1,351 @@
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.
=======================================================================
Spring Loaded 1.1.0:
Spring Loaded 1.1.0 includes a number of subcomponents with
separate copyright notices and license terms. The product that
includes this file does not necessarily use all the open source
subcomponents referred to below. Your use of the source
code for the these subcomponents is subject to the terms and
conditions of the following licenses.
SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES
>>> asm - 3.2
>>> asm-commons - 3.2
>>> asm-tree - 3.2
>>> asm-util - 3.2
-------------SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES------------------------------
BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES are applicable to the following component(s)
>>> asm - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2007 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-commons - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-tree - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
>>> asm-util - 3.2
ASM: a very small and fast Java bytecode manipulation framework
Copyright (c) 2000-2005 INRIA, France Telecom
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
[SPRINGLOADED110KL072612]

Binary file not shown.

View File

@@ -0,0 +1,47 @@
package example;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
public class MyMethodInterceptor implements MethodInterceptor {
static List<String> interceptedMethods = new ArrayList<String>();
public static boolean callSupers = true;
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
// System.out.println("intercepted:" + method);
interceptedMethods.add(method.toString());
if (callSupers) {
try {
proxy.invokeSuper(obj, args);
} catch (Throwable t) {
t.printStackTrace();
}
}
return null;
}
public static String interceptionLog() {
return "Interception list: " + interceptedMethods.toString();
}
public static void clearLog() {
interceptedMethods.clear();
}
public static void setCallSupers(boolean b) {
if (b) {
System.out.println("interceptorConfiguration: turning on super calls");
callSupers = true;
} else {
System.out.println("interceptorConfiguration: turning off super calls");
callSupers = false;
}
}
}

View File

@@ -0,0 +1,48 @@
package example;
import java.lang.reflect.UndeclaredThrowableException;
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.transform.impl.UndeclaredThrowableStrategy;
public class ProxyBuilder {
static <T> T createProxyFor(Class<T> clazz, MethodInterceptor mi) {
Enhancer enhancer = new Enhancer();
// if (classLoader != null) {
// enhancer.setClassLoader(classLoader);
// if (classLoader instanceof SmartClassLoader &&
// ((SmartClassLoader) classLoader).isClassReloadable(proxySuperClass)) {
// enhancer.setUseCache(false);
// }
// }
enhancer.setSuperclass(clazz);
enhancer.setStrategy(new UndeclaredThrowableStrategy(UndeclaredThrowableException.class));
enhancer.setInterfaces(null);//AopProxyUtils.completeProxiedInterfaces(this.advised));
enhancer.setInterceptDuringConstruction(false);
Callback[] callbacks = new Callback[] { mi };//getCallbacks(rootClass);
enhancer.setCallbacks(callbacks);
// enhancer.setCallbackFilter(new ProxyCallbackFilter(
// this.advised.getConfigurationOnlyCopy(), this.fixedInterceptorMap, this.fixedInterceptorOffset));
Class<?>[] types = new Class[callbacks.length];
for (int x = 0; x < types.length; x++) {
types[x] = callbacks[x].getClass();
}
enhancer.setCallbackTypes(types);
// Generate the proxy class and create a proxy instance.
// Object proxy;
// if (this.constructorArgs != null) {
// proxy = enhancer.create(this.constructorArgTypes, this.constructorArgs);
// }
// else {
@SuppressWarnings("unchecked")
T proxy = (T) enhancer.create();
// }
return proxy;
}
}

View File

@@ -0,0 +1,37 @@
package example;
public class ProxyTestcase {
static Simple proxy = ProxyBuilder.createProxyFor(Simple.class, new MyMethodInterceptor());
public static void main(String[] args) {
run();
}
public static void run() {
MyMethodInterceptor.clearLog();
proxy.moo();
System.out.println(MyMethodInterceptor.interceptionLog());
}
public static void runMoo() {
MyMethodInterceptor.clearLog();
proxy.moo();
System.out.println(MyMethodInterceptor.interceptionLog());
}
public static void runBar() {
MyMethodInterceptor.clearLog();
// proxy.bar(1, "abc", 3L); active in ProxyTestcase2
System.out.println(MyMethodInterceptor.interceptionLog());
}
public static void configureTest1() {
MyMethodInterceptor.setCallSupers(false);
}
public static void configureTest2() {
MyMethodInterceptor.setCallSupers(true);
}
}

View File

@@ -0,0 +1,29 @@
package example;
public class ProxyTestcase2 {
static Simple2 proxy;// = ProxyBuilder.createProxyFor(Simple2.class);
public static void main(String[] args) {
run();
}
public static void run() {
MyMethodInterceptor.clearLog();
proxy.boo();
System.out.println(MyMethodInterceptor.interceptionLog());
}
public static void runMoo() {
MyMethodInterceptor.clearLog();
proxy.moo();
System.out.println(MyMethodInterceptor.interceptionLog());
}
public static void runBar() {
MyMethodInterceptor.clearLog();
proxy.bar(1, "abc", 3L);
System.out.println(MyMethodInterceptor.interceptionLog());
}
}

View File

@@ -0,0 +1,8 @@
package example;
public class Simple {
void moo() {
System.out.println("Simple.moo() running");
}
}

View File

@@ -0,0 +1,17 @@
package example;
public class Simple2 {
void moo() {
System.out.println("Simple2.moo() running");
}
void boo() {
System.out.println("Simple2.boo() running");
}
public void bar(int i, String string, long l) {
System.out.println("Simple2.bar(" + i + "," + string + "," + l + ") running");
}
}

View File

@@ -0,0 +1 @@
com.test.plugins.ReloadEventProcessorPlugin1

View File

@@ -0,0 +1 @@
#com.test.plugins.ReloadEventProcessorPlugin1

View File

@@ -0,0 +1 @@
com.test.plugins.ReloadEventProcessorPlugin1

View File

@@ -0,0 +1,38 @@
/*******************************************************************************
* Copyright (c) 2011 SpringSource. All rights reserved.
*******************************************************************************/
package com.test.plugins;
import org.springsource.loaded.ReloadEventProcessorPlugin;
import org.springsource.loaded.TypeDelta;
import org.springsource.loaded.UnableToReloadEventProcessorPlugin;
/**
*
* @author Andy Clement
* @since 0.7.2
*/
public class ReloadEventProcessorPlugin1 implements ReloadEventProcessorPlugin, UnableToReloadEventProcessorPlugin {
public ReloadEventProcessorPlugin1() {
System.out.println("Instantiated ReloadEventProcessorPlugin1");
}
public void reloadEvent(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("ReloadEventProcessorPlugin1: reloadEvent(" + typename + "," + clazz.getName() + "," + encodedTimestamp
+ ")");
}
public void unableToReloadEvent(String typename, Class<?> clazz, TypeDelta typeDelta, String encodedTimestamp) {
System.out.println("ReloadEventProcessorPlugin1: unableToReloadEvent(" + typename + "," + clazz.getName() + ","
+ encodedTimestamp + ")");
}
@Override
public boolean shouldRerunStaticInitializer(String typename, Class<?> clazz, String encodedTimestamp) {
System.out.println("ReloadEventProcessorPlugin1: shouldRerunStaticInitializer(" + typename + "," + clazz.getName() + ","
+ encodedTimestamp + ")");
return false;
}
}

View File

@@ -0,0 +1,4 @@
package abs;
public abstract class AbsImpl implements Intface {
}

View File

@@ -0,0 +1,7 @@
package abs;
public abstract class AbsImpl2 implements Intface {
public int method() {
return 2;
}
}

Some files were not shown because too many files have changed in this diff Show More