• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Java Bridge : arrays and public fields
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Java Bridge : arrays and public fields


  • Subject: Java Bridge : arrays and public fields
  • From: Aram Greenman <email@hidden>
  • Date: Wed, 12 Feb 2003 22:30:09 -0800

This is regarding using Java objects in Obj-C code.

1. How does one pass or return Java arrays? For example, the following code crashes with SIGBUS:

id list = [[NSClassFromString(@"java.util.ArrayList") alloc] init];
id array = [list toArray];

2. Is it possible to access public fields of Java objects? My first thought was to use reflection, for example this Java code would get System.out:

Object out = Class.forName("java.lang.System").getField("out").get(System.class);

So in Obj-C:

Class class = NSClassFromString(@"java.lang.Class");
Class system = NSClassFromString(@"java.lang.System");

id out = [[[class forName:@"java.lang.System"] getField:@"out"] get:system];

2003-02-12 22:21:18.189 JavaBridgeTest[10438] *** Uncaught exception: <NSInvalidArgumentException> *** +[java/lang/System getField:]: selector not recognized

The problem is [class forName:@"java.lang.System"] returns the Obj-C class object "java/lang/System", same as NSClassForString(@"java.lang.System"), instead of an instance of java.lang.Class.

Thanks,

Aram
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: tableview filesystem
  • Next by Date: windowDidLoad
  • Previous by thread: tableview filesystem
  • Next by thread: windowDidLoad
  • Index(es):
    • Date
    • Thread