Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8011544

Allow subclassing Java classes from script without creating instances

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P2
    • 8
    • None
    • core-libs
    • None

    Description

      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)

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: