Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-225

Allow downcasts when initialising local vars in the BIND clause



      It would be very useful to be able to declare a local variable with some definite type yet provide an initialisation expression for the variable which computes a value whose lexical type is a supertype of the local variable. Clearly, this is only type safe when the dynamic type of the expression is the subtype (or one of its subtypes). There are many instances where a programmer can be sure this is the case even though the Byteman type-checker cannot, most notably with generics. For example:

      class Foo {
      public foo(List<String> names)

      { ... }


      RULE access generic info
      CLASS Foo
      METHOD foo(List)
      BIND firstName : String = $names.get(0);
      secondName : String = $names.get(1);
      IF firstName == "Andrew" && secondName == "Dinn"
      DO throw new NameException("you can't foo me");

      This change affects backwards compatibility in two way. Firstly, the type checker will no longer reject initialisations which were previously considered illegal. This may inconvenience users who prefer type correctness over the ability to downcast. Secondly, the type checker cannot use the declared type of the variable as a target type when type checking the initialisation expression. In rare cases this may mean that an initialisation expression whose type was previously constrained to a determinate type is no longer constrained. This may actually break rules which were previously valid.

      In order to allow this feature but also enable backwards compatibility the type checker should default to performing downcasts without dissent but provide an option to revert to the old behaviour (on both counts described above). The old behaviour should be provided if System property org.jboss.byteman.disallow.downcast is set to any value. It should also be possible for class Submit to be used to update this property as per all the other configuration options defined via System property settings.

        Gliffy Diagrams


            Issue Links



                • Assignee:
                  adinn Andrew Dinn
                  adinn Andrew Dinn
                • Votes:
                  0 Vote for this issue
                  1 Start watching this issue


                  • Created: