Skip to content
This repository was archived by the owner on Sep 29, 2020. It is now read-only.
This repository was archived by the owner on Sep 29, 2020. It is now read-only.

Static String returning methods from Imported classes are returning an object instead of a string #6

@JoseMonteagudo

Description

@JoseMonteagudo

I am running a little script importing a static class using this library as dependency on my Java 11 project. The return type of the function is object instead of a string how it used to be on my old project version using the Java 7 embedded Rhino Script Engine. So, I need to cast every function return to String in order to use the prototype functions of String.

try {
	var ImportedClasses = JavaImporter(com.StringUtils);

	with (ImportedClasses) {
	  var text = 'Test text';
	  document.write ('<br>typepf text: '+typeof text+'<br>');
	  var shouldBeString = StringUtils.methodReturningString ();
	  document.write ('<br>typepf shouldBeString: '+typeof shouldBeString+'<br>');
	}
}
catch (e) {
	document.write (e);
}

This script will print the following:

typepf text: string

typepf shouldBeString: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions