Is Elements updated to work with Java 9?

Asking because app is crashing on “Math.Sin” when producing java code from elements.

Hrmm that shouldn’t happen. Yes Java 9 should be working fine (I’m using it locally for the test suite). Can you give me a more complete example of what crashes?

When trying to use Sin funciton i get NoClassDefFoundError sun/misc/CharacterEncoder

It looks like it has some problems with global functions

Can you give us a complete project or piece of code that shows this?

rotateSin := Sin( -FRotationAngle ) ;
where Sin is defined :

type
function Sin ( const _val : Double
) : Double ;

and is implemented :

function Sin(
const _val : Double
) : Double ;
begin
Result := Math.Sin( _val ) ;
end ;

I cant give you complete project

Thanks, logged as bugs://78971

Tried this:

namespace consoleapplication544;

interface

uses
  java.util;

type
  ConsoleApp = class
  public
    class method Main(args: array of String);
  end;
//type
function Sin ( const _val : Double
) : Double ;
//and is implemented :

implementation
function Sin(
const _val : Double
) : Double ;
begin
Result := Math.Sin( _val ) ;
end ;

class method ConsoleApp.Main(args: array of String);
begin
  Sin(15);
end;

end.

and it works fine in jre1.9; what am I missing?

bugs://78971 got closed with status cannotrepro.

And how do you compile it on Java 9 when rt.jar is no longer in there?

Thanks, logged as bugs://79002

Hrmm this is freaky; looks like something went wrong in me trying Java9. Running works, compiling against not yet. Logged a bug to support that for an upcoming version.

I run our jar library on Java 9.0.4 Windows clean machine and got error :
_java.lang.NoClassDefFoundError: sun/misc/CharacterEncoder at com.jdk._Global.CanonicalWKT(SourceFile)
Here is sample method code :

  function CanonicalWKT(
    const _wkt : String
  ) : String ;
  var
    i   : Integer ;
    r   : TStringBuilder ;
    chs : TCharSet ;
  begin
    Result := '' ;
    r := TStringBuilder.Create( 255 ) ;
    try
      chs := PrepareCharSet( [ 'AZ', 'az', '_', '+', '-', '/', '09' ] ) ;
      for i := StringFirst to StringLast( _wkt ) do begin
        if InCharSet( _wkt[i], chs ) then
          r.Append( _wkt[i] )
        else begin
          if ( r.Length         >  0    ) and
             ( r[ r.Length -1 ] <> '_'  )
          then
            r.Append( '_' )
        end ;
      end ;
      Result := r.ToString() ;
    finally
      FreeObject( r )
    end;
  end ;

The jar was generated with latest Elements 9.3 version and works with latest Java 8. What can be wrong ?

Odd failure. can you make this fail outside of your project?

Do note that in v9
sun.misc.Base64Encoder
(and it’s base class sun.misc.CharacterEncoder) is gone. You do see to use it in your project.

Bingo. Yes, we use sun.misc.Base64Encoder for http authorization in one line but in another line java.util.Base64. I will change this line and make another test. Thanks.

It works :slight_smile: great, thanks for info.

2 Likes

FWIW, if you use EBuild, you can also compile against JDK9 now, in Fire and Water (VS support for EBuild coming soon).

bugs://E20500 was closed as fixed.