Allow subclassing Java classes from script without creating instances

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P2
    • 8
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      Currently, the only way to subclass a Java class in Nashorn is to create an instance a la anonymous inner classes in Java:

          var r = new java.lang.Runnable() {
              run: function() { ... }
          }

      However, sometimes we need to create a subclass without creating instances. We'd need a functionality like:

          var R = Java.extend(java.lang.Runnable, {
              run: function() { ... }
          })

      Such a class can then be instantiated:

         var r = new R

      Or passed to some other API, i.e.:

        launch(R.class)

            Assignee:
            Attila Szegedi
            Reporter:
            Attila Szegedi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: