comp.lang.ada
 help / color / mirror / Atom feed
* Help: Problem with JGnat
@ 2002-08-02  4:35 Bin Chen
  0 siblings, 0 replies; 7+ messages in thread
From: Bin Chen @ 2002-08-02  4:35 UTC (permalink / raw)


Hi,

I used jgnat compile the following Ada program to Java bytecode, it was OK,
but when I ran the .class file, it always threw the following exception.
Could you give me any feedback?

Thank you.

Bin Chen


Exception:

Exception in thread "main" java.lang.IllegalMonitorStateException
        at
jgnat.adalib.system$task_primitives$operations.write_lock__2(s-taprop.adb:22
9)
        at
jgnat.adalib.system$task_primitives$operations.lock_all_tasks_list(s-taprop.
adb:771)
        at
jgnat.adalib.system$task_primitives$operations.enter_task(s-taprop.adb:373)
        at
jgnat.adalib.system$task_primitives$operations.initialize(s-taprop.adb:834)
        at jgnat.adalib.system$tasking._elabb(s-taskin.adb:186)
        at ada_main.adainit(b~main.adb:89)
        at main.main(main.adb)

Sources:

--Pack_Factorial.ads
package Pack_Factorial is
  task type Task_Factorial is --Specification
    entry Start( F:in Positive ); --Rendezvous
    entry Finish( Result:out Positive ); --Rendezvous
  end Task_Factorial;
end Pack_Factorial;

--Pack_Factorial.adb
package body Pack_Factorial is
  task body Task_Factorial is --Implementation
    Factorial : Positive;
    Answer : Positive := 1;
  begin
    accept Start( F:in Positive ) do --Factorial
      Factorial := F;
    end Start;
    for I in 2 .. Factorial loop --Calculate
      Answer := Answer * I;
    end loop;
    accept Finish( Result:out Positive ) do --Return answer
      Result := Answer;
    end Finish;
  end Task_Factorial;
end Pack_Factorial;

--main.adb
with Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
use Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
procedure main is
 Thread_1 : Task_Factorial;
 Factorial: Positive;
begin
 Thread_1.Start(5); --Start factorial calculation
 Put("Factorial 5 is ");
 Thread_1.Finish( Factorial ); --Obtain result
 Put( Factorial ); New_Line;
end Main;








^ permalink raw reply	[flat|nested] 7+ messages in thread
* Help: Problem with JGnat
@ 2002-08-02  2:46 Bin Chen
  2002-08-02  8:04 ` Dr. Michael Paus
  0 siblings, 1 reply; 7+ messages in thread
From: Bin Chen @ 2002-08-02  2:46 UTC (permalink / raw)


Hi,

I used jgnat compile the following Ada program to Java bytecode, it was OK,
but when I ran the .class file, it always threw the following exception.
Could you give me any feedback?

Thank you.

Bin Chen


Exception:

Exception in thread "main" java.lang.IllegalMonitorStateException
        at
jgnat.adalib.system$task_primitives$operations.write_lock__2(s-taprop.adb:22
9)
        at
jgnat.adalib.system$task_primitives$operations.lock_all_tasks_list(s-taprop.
adb:771)
        at
jgnat.adalib.system$task_primitives$operations.enter_task(s-taprop.adb:373)
        at
jgnat.adalib.system$task_primitives$operations.initialize(s-taprop.adb:834)
        at jgnat.adalib.system$tasking._elabb(s-taskin.adb:186)
        at ada_main.adainit(b~main.adb:89)
        at main.main(main.adb)

Sources:

--Pack_Factorial.ads
package Pack_Factorial is
  task type Task_Factorial is --Specification
    entry Start( F:in Positive ); --Rendezvous
    entry Finish( Result:out Positive ); --Rendezvous
  end Task_Factorial;
end Pack_Factorial;

--Pack_Factorial.adb
package body Pack_Factorial is
  task body Task_Factorial is --Implementation
    Factorial : Positive;
    Answer : Positive := 1;
  begin
    accept Start( F:in Positive ) do --Factorial
      Factorial := F;
    end Start;
    for I in 2 .. Factorial loop --Calculate
      Answer := Answer * I;
    end loop;
    accept Finish( Result:out Positive ) do --Return answer
      Result := Answer;
    end Finish;
  end Task_Factorial;
end Pack_Factorial;

--main.adb
with Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
use Ada.Text_Io, Ada.Integer_Text_Io, Pack_Factorial;
procedure main is
 Thread_1 : Task_Factorial;
 Factorial: Positive;
begin
 Thread_1.Start(5); --Start factorial calculation
 Put("Factorial 5 is ");
 Thread_1.Finish( Factorial ); --Obtain result
 Put( Factorial ); New_Line;
end Main;






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-08-02 18:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02  4:35 Help: Problem with JGnat Bin Chen
  -- strict thread matches above, loose matches on Subject: below --
2002-08-02  2:46 Bin Chen
2002-08-02  8:04 ` Dr. Michael Paus
2002-08-02 12:29   ` Marc A. Criley
2002-08-02 16:04     ` Bin Chen
2002-08-02 18:55       ` David Marceau
2002-08-02 18:37     ` Robert Dewar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox