Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9423 > unrolled thread
| Started by | simplicity <stella_pigeon@live.ca> |
|---|---|
| First post | 2011-11-02 22:04 -0700 |
| Last post | 2011-11-03 08:15 -0700 |
| Articles | 7 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
Trivial question? simplicity <stella_pigeon@live.ca> - 2011-11-02 22:04 -0700
Re: Trivial question? markspace <-@.> - 2011-11-02 22:54 -0700
Re: Trivial question? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-03 08:24 +0000
Re: Trivial question? simplicity <stella_pigeon@live.ca> - 2011-11-03 10:28 -0700
Re: Trivial question? Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-11-03 22:13 +0000
Re: Trivial question? Roedy Green <see_website@mindprod.com.invalid> - 2011-11-03 08:14 -0700
Re: Trivial question? Roedy Green <see_website@mindprod.com.invalid> - 2011-11-03 08:15 -0700
| From | simplicity <stella_pigeon@live.ca> |
|---|---|
| Date | 2011-11-02 22:04 -0700 |
| Subject | Trivial question? |
| Message-ID | <9ae6e06c-222e-4911-97e8-af9511b8772a@t38g2000prg.googlegroups.com> |
Why do the examples always have to be completely disconnected from the reality? I am trying to create a simple prototype which interfaces with the native DLL using JNA. So, following the JNA tutorial, I specify the native function as int func(int) just as it is in the C++ header. When I run the java program it fails with "module not found" exception. After a bit of digging inside the DLL I see that it rightly so: my function is actually _func@0 rather than func. OK, so back to Java code and change the the native to what it really is. Syntax error!!! Java will not take _func@0 as a function name. Because of "@", I guess. So, here is my "trivial question": How can I put this name with "@" to allow Java to digest it without complaints?
[toc] | [next] | [standalone]
| From | markspace <-@.> |
|---|---|
| Date | 2011-11-02 22:54 -0700 |
| Message-ID | <j8taa8$rur$1@dont-email.me> |
| In reply to | #9423 |
On 11/2/2011 10:04 PM, simplicity wrote: > So, here is my "trivial question": How can I put this name with "@" to > allow Java to digest it without complaints? To me this is really a question of knowing your compiler, not Java. Java doesn't allow @ signs in identifiers, period. You'll have to make an identifier that Java can accept. One without an @ sign. Hence, you'll need to ask on your compiler help list how to get rid of the @. Some compilers support an option to remove the name mangling (the @), some you have an assembler that you can use to bridge the gap between C output and another language. It all depends on your long term goals, and what your language is capable of.
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2011-11-03 08:24 +0000 |
| Message-ID | <slrnjb4jts.fvg.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #9425 |
markspace <-@> wrote:
> On 11/2/2011 10:04 PM, simplicity wrote:
>> So, here is my "trivial question": How can I put this name with "@" to
>> allow Java to digest it without complaints?
> To me this is really a question of knowing your compiler, not Java.
> Java doesn't allow @ signs in identifiers, period. You'll have to make
> an identifier that Java can accept. One without an @ sign. Hence,
> you'll need to ask on your compiler help list how to get rid of the @.
> Some compilers support an option to remove the name mangling (the @),
> some you have an assembler that you can use to bridge the gap between C
> output and another language. It all depends on your long term goals,
> and what your language is capable of.
extern "C" {
...
int func(...) { ... }
...
}
might help a lot, too. (just guessing)
[toc] | [prev] | [next] | [standalone]
| From | simplicity <stella_pigeon@live.ca> |
|---|---|
| Date | 2011-11-03 10:28 -0700 |
| Message-ID | <8c4f88f0-b444-40ae-b615-77eb4eae2426@x2g2000vbd.googlegroups.com> |
| In reply to | #9435 |
On Nov 3, 2:24 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
wrote:
> markspace <-@> wrote:
> > On 11/2/2011 10:04 PM, simplicity wrote:
> >> So, here is my "trivial question": How can I put this name with "@" to
> >> allow Java to digest it without complaints?
> > To me this is really a question of knowing your compiler, not Java.
> > Java doesn't allow @ signs in identifiers, period. You'll have to make
> > an identifier that Java can accept. One without an @ sign. Hence,
> > you'll need to ask on your compiler help list how to get rid of the @.
> > Some compilers support an option to remove the name mangling (the @),
> > some you have an assembler that you can use to bridge the gap between C
> > output and another language. It all depends on your long term goals,
> > and what your language is capable of.
>
> extern "C" {
> ...
> int func(...) { ... }
> ...
>
> }
>
> might help a lot, too. (just guessing)
This will work but I hoped there would be a way to do it without
creating an extra layer between Java and the DLL. I actually found a
package called xFunction that is similar to JNA and actually allows me
to define native modules with "@", something like
xFunction func = new xFunction("my_dll_library", "int _func@0(int)");
and execute it
int rc = ((Integer) func.invoke(1)).intValue();
so, apparently, there is a way. I hoped that there might be something
as simple as the syntax I am not aware of.
[toc] | [prev] | [next] | [standalone]
| From | Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> |
|---|---|
| Date | 2011-11-03 22:13 +0000 |
| Message-ID | <slrnjb64gb.fvg.avl@gamma.logic.tuwien.ac.at> |
| In reply to | #9456 |
simplicity <stella_pigeon@live.ca> wrote:
> On Nov 3, 2:24 am, Andreas Leitgeb <a...@gamma.logic.tuwien.ac.at>
> wrote:
>> markspace <-@> wrote:
>> > On 11/2/2011 10:04 PM, simplicity wrote:
>> >> So, here is my "trivial question": How can I put this name with "@" to
>> >> allow Java to digest it without complaints?
>> > To me this is really a question of knowing your compiler, not Java.
>> > Java doesn't allow @ signs in identifiers, period. You'll have to make
>> > an identifier that Java can accept. One without an @ sign. Hence,
>> > you'll need to ask on your compiler help list how to get rid of the @.
>> > Some compilers support an option to remove the name mangling (the @),
>> > some you have an assembler that you can use to bridge the gap between C
>> > output and another language. It all depends on your long term goals,
>> > and what your language is capable of.
>> extern "C" {
>> int func(...) { ... }
>> }
>> might help a lot, too. (just guessing)
> This will work but I hoped there would be a way to do it without
> creating an extra layer between Java and the DLL.
Seems like I misunderstood your problem. I thought, the DLL was yours,
so you'd extern-"C"-wrap the relevant functions within the DLL and then
use it trivially from Java.
If it's not your own DLL, then I understand, that my solution doesn't
satisfy you. :-/
Either xFunction does have its own code between the DLL and Java, or
(if it is pure java itself) you could examine how it does the magic.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2011-11-03 08:14 -0700 |
| Message-ID | <ttb5b7diji7r5cdclqrdr61r1ats1nsah7@4ax.com> |
| In reply to | #9423 |
On Wed, 2 Nov 2011 22:04:47 -0700 (PDT), simplicity <stella_pigeon@live.ca> wrote, quoted or indirectly quoted someone who said : >I am trying to create a simple prototype which interfaces with the >native DLL using JNA You might think that was a typo for JNI. They have similar purposes. See http://mindprod.com/jgloss/jna.html http://mindprod.com/jgloss/jni.html -- Roedy Green Canadian Mind Products http://mindprod.com Capitalism has spurred the competition that makes CPUs faster and faster each year, but the focus on money makes software manufacturers do some peculiar things like deliberately leaving bugs and deficiencies in the software so they can soak the customers for upgrades later. Whether software is easy to use, or never loses data, when the company has a near monopoly, is almost irrelevant to profits, and therefore ignored. The manufacturer focuses on cheap gimicks like dancing paper clips to dazzle naive first-time buyers. The needs of existing experienced users are almost irrelevant. I see software rental as the best remedy.
[toc] | [prev] | [next] | [standalone]
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2011-11-03 08:15 -0700 |
| Message-ID | <90c5b7pbts7q7i0t8attni2i8kahf0cg1r@4ax.com> |
| In reply to | #9423 |
On Wed, 2 Nov 2011 22:04:47 -0700 (PDT), simplicity <stella_pigeon@live.ca> wrote, quoted or indirectly quoted someone who said : > >So, here is my "trivial question": How can I put this name with "@" to >allow Java to digest it without complaints? You would put a C wrapper around it with a Java-friendly name. -- Roedy Green Canadian Mind Products http://mindprod.com Capitalism has spurred the competition that makes CPUs faster and faster each year, but the focus on money makes software manufacturers do some peculiar things like deliberately leaving bugs and deficiencies in the software so they can soak the customers for upgrades later. Whether software is easy to use, or never loses data, when the company has a near monopoly, is almost irrelevant to profits, and therefore ignored. The manufacturer focuses on cheap gimicks like dancing paper clips to dazzle naive first-time buyers. The needs of existing experienced users are almost irrelevant. I see software rental as the best remedy.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web