Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

I need help on using the Java Native Interface (JNI)

(Jun 30, 2015 04:18 PM)JavaProphet Wrote:  @peaksoonpeak I do this. I posted an old function, perhaps you looked at that? I updated it quickly after I posted. I loop over the function, and get the match count, then multiply it by the equivalent of THE-A length, then allocate it all at once.

Anyways, here's what I have now:
Code
char* replace(char* input, char* rf, char* rt) {
    size_t isl = strlen(input);
    size_t rfsl = strlen(rf);
    size_t rtsl = strlen(rt);
    size_t ml = 0;
    size_t mc = 0;
    int i = 0;
    for (; i < isl; i++) {
        bool im = input[i] == rf[ml];
        if (im) {
            ml++;
            if (ml == rfsl) {
                mc++;
                ml = 0;
                continue;
            }
        } else if (ml > 0) {
            ml = 0;
        }
    }
    i = 0;
    ml = 0;
    char* output = malloc(isl - ((rfsl - rtsl) * mc));
    output[0] = '\0';
    int mi = 0;
    for (; i < isl; i++) {
        bool im = input[i] == rf[ml];
        if (im) {
            ml++;
            if (ml == rfsl) {
                size_t os = mi - ml + 1;
                strcpy(output + os, rt);
                mi += ml - rtsl - 1;
                ml = 0;
                continue;
            }
        } else if (ml > 0) {
            ml = 0;
        }
        output[mi++] = input[i];
    }
    output[mi] = '\0';
    return output;
}

As to your PM i stay away from skype, come join IRC irc.#.net everyone there is helpful :)

my alias is error

edit:
try

chat.#.net - kiwi IRC web client.
(Jun 30, 2015 04:43 PM)JavaProphet Wrote:  @Systemic They're all acronyms, it's just how I prefer to write code. I never intended on publishing it in any manner.

If I really need an efficient String operation in Java, I just start working with char[]. Unfortunately the array system is not as fleshed out as C, due to a lack of pointers.

No problem there, it was just a suggestion. char[] that isn't copied on a method like ".toCharArray()" is pretty much your best bet.
Java arrays are fine, they were designed to be safe.
(Jun 30, 2015 04:46 PM)JavaProfit Wrote:  No problem there, it was just a suggestion. char[] that isn't copied on a method like ".toCharArray()" is pretty much your best bet.
Java arrays are fine, they were designed to be safe.

Safe yes, but I have only begun to use C, and when I write Java, I miss pointers already.
I'm considering learning D too. It's almost C-level Java.
And alright peak.
(Jun 30, 2015 01:09 PM)BinaryBit Wrote:  No need to be rude. Also, all of the libraries in Java lead up to C or C++. Without natives, you couldn't do anything in Java, really. You're not very smart for not thinking about that. I can't do it, because I cannot understand any of the tutorials online. And, if it's very simple, please help me out, as that is the point of this thread. Thank-you.

And without ASM you can't use C or C++, retard! Hurr!

Fucking moron. Shut the fuck up.

Every single response you give to people adds a new cancer cell to my brain just from trying to process your stupidity.

Why in all fucks do you bash on a language you don't know SHIT about?

If you can't even understand the most simplistic tutorials online (although they are shitty, I may say myself), then you are the dumb fuck here.

tldr stop posting here.

P.S. You can achieve anything in Java without using the JNI. You're an absolute fucking moron if you believe otherwise. It's just the way it is accomplished, that's all.
(Jun 30, 2015 11:52 PM)Sparta. Wrote:  And without ASM you can't use C or C++, retard! Hurr!

Fucking moron. Shut the fuck up.

Every single response you give to people adds a new cancer cell to my brain just from trying to process your stupidity.

Why in all fucks do you bash on a language you don't know SHIT about?

If you can't even understand the most simplistic tutorials online (although they are shitty, I may say myself), then you are the dumb fuck here.

tldr stop posting here.

P.S. You can achieve anything in Java without using the JNI. You're an absolute fucking moron if you believe otherwise. It's just the way it is accomplished, that's all.

Dude, are you high on drugs, or just have high-functioning autism? You seem like one of those highly-raged little kids in your everyday voice communication in Team Fortress 2. I like how you lowered my rep 2 more times because you are so butthurt. I don't even know what you are saying anymore. I hope to god that you are trolling because, if not, you are obviously disabled (no offense to you, but I said it for truth's sake).
Please no flaming and if this turns into a C thread I'll havw to move it.
(Jul 1, 2015 02:41 AM)MrOrang Wrote:  Please no flaming and if this turns into a C thread I'll havw to move it.

This is not a C thread, it is a thread on the Java Native Interface which involves using C, but is still Java. Also, I hate flaming, and that enraged disabled user had to do it. Also, could you consider getting a Java Native Interface (JNI) subsection created, since the JNI is both revolved around C and Java? Thank-you.
(Jul 1, 2015 08:33 PM)BinaryBit Wrote:  This is not a C thread, it is a thread on the Java Native Interface which involves using C, but is still Java. Also, I hate flaming, and that enraged disabled user had to do it. Also, could you consider getting a Java Native Interface (JNI) subsection created, since the JNI is both revolved around C and Java? Thank-you.

He isn't even a moderator/administrator you fucking idiot.

JNI is apart of Java, so it stays in the Java section. Anything C related goes to the C section.

You are the most fallacious and ignorant person here by far. You claim in the OP that you "know a lot about Java"; then why the fuck are you asking for help? 🤣
(Jul 1, 2015 09:40 PM)Sparta. Wrote:  He isn't even a moderator/administrator you fucking idiot.

JNI is apart of Java, so it stays in the Java section. Anything C related goes to the C section.

You are the most fallacious and ignorant person here by far. You claim in the OP that you "know a lot about Java"; then why the fuck are you asking for help? 🤣

He's gotta make sure the entire HF 1337 SQUAD knows that he's too smart for them so he has to ask things that he can answer himself.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by kinsellaAug 11, 2018 01:32 PM 3 324 Aug 11, 2018 01:32 PM
Last Post: XMR
[Java] by JavaProphetApr 21, 2015 07:38 PM 0 284 Apr 21, 2015 07:38 PM
Last Post: JavaProphet
[C] by Zy0nApr 10, 2015 12:55 PM 3 77 Apr 10, 2015 12:55 PM
Last Post: g4143