beanshell
beanshell copied to clipboard
Progress update 2
Ok changelog... lets see what we've gots.
Changes to note
The following may effect existing code and implementation, if you disagree with these changes or it breaks something you are using lets discuss.
- Lazy initialize class static context.
- Moved the static block evaluation to
to be initialised only when needed.
This has the following impact:
global_var = 1;
class AB {
static int lazy = global_var;
}
global_var = 2;
assertEquals(2, AB.lazy); // lazy initialise
global_var = 3;
assertEquals(2, AB.lazy);
- Java 9 and 10 with
--illegal-access=deny
passes
- JDK9+ does not have rt.jar anymore gracefully ignore boot class path
- Skip accessibility tests if haveAccessibility false. We assume that you have accessibility to test accessibility.
- compile and run tests with accessibility=false (default) now succeeds with --illegal-access=deny with Java 9 or Java 10. Add jdk9 with --illegal-access=deny to travis script
- Tests all pass!!!!! Whoop whoop. Time to break things again so let those tests roll in.
- If run with
-Daccessibility=true
all tests are executed and should succeed. Travis build. - default is still accessibility false for which there are 5 tests that are skipped.
- No access modifiers (java's package private) is now public
- this is the default behaviour ,regardless of accessibility, if no access modifiers (or package private) bsh default is public visibility
- includes class, constructor, methods and fields
The setAccessibility solution, governed via a static variable Capabilities.hasAccessibility()
is of course not thread safe Java 10 appears to be reluctant to change accessibility and appears to blatantly refuse certain illegal access like package private constructors etc. Is it worth the effort? This is why the move towards pubic first makes sense and perhaps it is time we get rid of setAccessible too? Thoughts?
- Completed merge with pejobo/beanshell2
- We are now up to date, all enhancements deemed useful were merged from the beanshell2 fork.
- Update dependency modules
- ph-javacc-maven-plugin version 4.x uses the new javacc fork ParserGeneratorCC see https://github.com/phax/ParserGeneratorCC don't have an opinion yet seems like half a dozen of the same.
- TokenMgrError was made redundant by ParserGeneratorCC so we remove it as well
- added bsh.debugClasses as a system property for specifying the location to save generated class files.
New features
- Varargs method implementation.
- added ELLIPSIS to the grammar and let FormalParameter receive isVarArgs token.
- implemented Types.isSignatureVarargsAssignable for method signature comparison.
- make type parameter an array of Type if isVarArgs
- implement method invocation and appropriate type casting for isVarArgs
- Implement interfaces
- interfaces are now GeneratedClasses with bshstatic This namespace
- implemented public static final constant fields
- Implement interface methods (default and static)
- implement interface static methods, only accessible on interface
- implement interface default methods, inherited by class, overridden by class or interface extends, accessible as class instance method
- implemented try-with-resources
- added new grammar for try TryWithResources and AutoCloseable
- implemented BSHAutoCloseable as a subclass of BSHTypedVariableDeclaration to reuse the variable evaluation.
- BSHTryWithResources acts as the collection of resources and interface for evaluating and closing the resources.
- added a lookup for 1st Block node to BSHTryStatement to avoid the use of magic numbers
- on eval start if the 1st Node is TryWithResources we keep a reference and call eval which will create the variables in the namespace in callstack
- in the finally block of the try block evaluation, if we have a reference to BSHTryWithResources we auto close, which ensures that all resources are closed.
- suppressed on close exceptions will be collected in the target exception from the try block
- Implement try multi catch
- add grammar to parse multi catch
- implement evaluation of catch block with a list of types
- improve check assignability to avoid the previous try fail catch continue manoeuvres
- enable ability to throw throwable and subtypes - previously limited to exception types only
- added some simple multi catch tests
- Abstract methods implemented validation and inheritance rules.
- validate abstract methods are implemented or class declared abstract
- bsh classes are virtual abstract only or iow abstract classes can be instantiated
- apply inheritance rules overridden methods may not reduce visibility
- Implemented Final modifier validation
- improved final re-assignment validation
- fixed final static is set validation includes static block assignment
- fixed instance final variable set includes constructor assignment
- added final class cannot extend validation
- added final method cannot override validation
- Generics/Type parameters re-implemented.
- re-approached the generics issue, made all generics parseable and cleaned up the grammar
- implemented generics raw types, by type casting single character class name not found to java.lang.Object
- resolved the "null fromValue" bug
- resolves 10 previously failing tests now not marked as known issues to be skipped anymore
- collected all the generics tests into a new unit test TypeParameters test with several test additions Improved generics capture.
- Correctly capture nested type parameters, with tests.
- Correctly ignore < and > in if statements.
- Loose-typed object fields.
- make loose typed fields proper citizens
- infer loose typed field type from value at assignment
- expose namespace variables as object fields
- expose namespace fields for inheritance
- Implement variable declared array.
- Implementation of
byte array[] = new byte[0];
- Allow multi dimensions
- Include primitive and object typed arrays
- Implement JDK7 number literal additions.
- implement the JDK7, aka project coin, number literal additions
- add binary number literals ex.
0b010101
- correctly parsing and processing underscores in numeric literals
0B_0111_1101
- Upgrade servlet jar and added
run_servlet.sh
- Added script to download jetty servlet container to target folder, create a flat war structure and start the servlet container.
Fixes Improvements
- Fix calling overridden method from child instance
- correct preference for choosing overridden method based on class hierarchy
- fix bug loosing correctly chosen class method
- fix initialise class instance This and instance init for calling overridden method from super constructor
- fix inherit loose-typed class instance fields
- less specific is assignable by most specific unless signature is a match
- improved varargs matching no argument or null type as varargs
- Enhanced for, collection manager and reflection.
- Improved Collection manager: everything and anything now iterable.
** Added iterate over number range from 0 up to number or 0 down to number.
** Added unicode character code point range with nearest block set start. iterate over
a - z, A - Z, 0 - 9, \ u16A0 - \ u16F8
etc... ** over a string representation of type member reflection detail Includes class definition and produces the true bsh virtual information for generated classes. Allows reflection iteration via class type, object instance or class identifier.
- Fix import static
- Added field and method static import, previously only
*
static import was available.
- Fixed deprecation
- Java 9 and 10 deprecations were addressed
- Fixed the deprecation warnings for applets and made a valiant attempt at turning the applets into apps, gui api not my strong suite. Anyone want to improve on that?
- Many Improvements to OldScriptsTest. now called BshScriptTestCase
- Added system property
script
to single out a single script for testing. - improved error reporting
- Wrap junit asserts for script tests. see
Assert.bsh
- add ability to skip tests based on assumptions
- and more - these are starting to be be choice for writing tests
- Fixes to inner class implementation.
- Correctly fail on required enclosing instance when trying to instantiate an inner class from static outer class
- Added
Instance.new Innerclass()
parsing and capability for instantiating an innerclass from outer instance
- Upgrade ASM 6.1.1
- Applied fixes as per changes to ASM api including deprecated method changes to visitMethodInsn
- As before we still don't need ClassReader so gutted it out of the ASM API.
- We also don't need Annotation or Module support so that got purged too.
- Script engine changes.
- reduced code duplication
- converted TestBshScriptEngine to junit test.
- Remove BSF2.x support in favour of JSR223 support. BSF engine moved to external module bsh-bsf-engine for anyone that might still require it.
-
Improved callerInfo retention for reporting errors from generated methods..
-
Fix override child namespace for namespace chaining. A method inherited from a parent namespace refers to a variable changed in the local namespace, we should override the method declared namespace with the child's namespace.
nJoy!
String Literals
You can now use single quotes '
with strings in bsh. Single quoted string literals of 1 character length will be treated as a Primitive.TYPE = char
but if it contains anything more or less than a single character it is treated as a string.
The following is therefor true:
https://github.com/beanshell/beanshell/blob/7a6181a55a13fd3ae4a0ee4a83e6fb0fca40c19a/src/test/resources/test-scripts/strings.bsh#L5-L18
https://github.com/beanshell/beanshell/blob/7a6181a55a13fd3ae4a0ee4a83e6fb0fca40c19a/src/test/resources/test-scripts/strings.bsh#L20-L49
You just rock!
Ste
On Fri, Jun 8, 2018 at 10:59 AM, Nick Lombard [email protected] wrote:
String Literals
You can now use single quotes ' you strings in bsh. Single quoted string literals of 1 character length will be treated as a Primitive.TYPE = char but if it contains anything more or less than a single character it is treated as a string.
The following is therefor true:
https://github.com/beanshell/beanshell/blob/7a6181a55a13fd3ae4a0ee4a83e6fb 0fca40c19a/src/test/resources/test-scripts/strings.bsh#L5-L18
https://github.com/beanshell/beanshell/blob/7a6181a55a13fd3ae4a0ee4a83e6fb 0fca40c19a/src/test/resources/test-scripts/strings.bsh#L20-L49
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/beanshell/beanshell/issues/68#issuecomment-395697409, or mute the thread https://github.com/notifications/unsubscribe-auth/AACoglt8BwKrIubeVl66StavtuNy64xTks5t6jzUgaJpZM4UfkvV .
@stefanofornari I can always count on your support =) Tx