public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Must unwind in gcc be ported for gcj?
@ 2011-02-24  1:19 majia gm
  2011-02-24  2:34 ` David Daney
  2011-02-24 10:07 ` Bryce McKinlay
  0 siblings, 2 replies; 3+ messages in thread
From: majia gm @ 2011-02-24  1:19 UTC (permalink / raw)
  To: Java List; +Cc: gcc-help

Hi, everyone.

I'm porting gcj (gcc-4.4.2) to another platform. Right now the gij
fails when interpreting the following program.

File A.java:

import B;
public class A{

	public static void main(String args[])
	{
		try{
			B b=(B)Class.forName("B").newInstance();
		catch(Exception e)
		{
			System.out.println("Cannot find Class B");
		}
	}
}

File B.java:

public class B
{}

I use gdb to track gij, and I found GetCallingClass() in forName()
returns NULL, then the bootstrap loader is used to search the Class B
but with no result. Should the Class B has the same class loader, the
system class loader as the Class A dose?

Then I track the GetCallingClass(), and I found it needs the unwind
function provided by gcc.  Must I port the unwind function?

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

* Re: Must unwind in gcc be ported for gcj?
  2011-02-24  1:19 Must unwind in gcc be ported for gcj? majia gm
@ 2011-02-24  2:34 ` David Daney
  2011-02-24 10:07 ` Bryce McKinlay
  1 sibling, 0 replies; 3+ messages in thread
From: David Daney @ 2011-02-24  2:34 UTC (permalink / raw)
  To: majia gm; +Cc: Java List, gcc-help

On 02/23/2011 05:19 PM, majia gm wrote:
> Hi, everyone.
>
> I'm porting gcj (gcc-4.4.2) to another platform. Right now the gij
> fails when interpreting the following program.
>
> File A.java:
>
> import B;
> public class A{
>
> 	public static void main(String args[])
> 	{
> 		try{
> 			B b=(B)Class.forName("B").newInstance();
> 		catch(Exception e)
> 		{
> 			System.out.println("Cannot find Class B");
> 		}
> 	}
> }
>
> File B.java:
>
> public class B
> {}
>
> I use gdb to track gij, and I found GetCallingClass() in forName()
> returns NULL, then the bootstrap loader is used to search the Class B
> but with no result. Should the Class B has the same class loader, the
> system class loader as the Class A dose?
>
> Then I track the GetCallingClass(), and I found it needs the unwind
> function provided by gcc.  Must I port the unwind function?
>

Short answer: Yes.

libgcj relies internally on exception handling.

You might be able to construct simple programs that don't throw 
exceptions, but they are kind of a core language feature.

As you saw, the runtime startup code does throw and catch exceptions.

David Daney

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

* Re: Must unwind in gcc be ported for gcj?
  2011-02-24  1:19 Must unwind in gcc be ported for gcj? majia gm
  2011-02-24  2:34 ` David Daney
@ 2011-02-24 10:07 ` Bryce McKinlay
  1 sibling, 0 replies; 3+ messages in thread
From: Bryce McKinlay @ 2011-02-24 10:07 UTC (permalink / raw)
  To: majia gm; +Cc: Java List, gcc-help

On Thu, Feb 24, 2011 at 1:19 AM, majia gm <gmmajia@gmail.com> wrote:
> Hi, everyone.
>
> I'm porting gcj (gcc-4.4.2) to another platform. Right now the gij
> fails when interpreting the following program.
>
> File A.java:
>
> import B;
> public class A{
>
>        public static void main(String args[])
>        {
>                try{
>                        B b=(B)Class.forName("B").newInstance();
>                catch(Exception e)
>                {
>                        System.out.println("Cannot find Class B");
>                }
>        }
> }
>
> File B.java:
>
> public class B
> {}
>
> I use gdb to track gij, and I found GetCallingClass() in forName()
> returns NULL, then the bootstrap loader is used to search the Class B
> but with no result. Should the Class B has the same class loader, the
> system class loader as the Class A dose?
>
> Then I track the GetCallingClass(), and I found it needs the unwind
> function provided by gcc.  Must I port the unwind function?
>

Have a look at SJLJ_EXCEPTIONS. This should allow you to get something
working without having to port the full unwinder.

Bryce

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

end of thread, other threads:[~2011-02-24 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24  1:19 Must unwind in gcc be ported for gcj? majia gm
2011-02-24  2:34 ` David Daney
2011-02-24 10:07 ` Bryce McKinlay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).