Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    John Vilk
    @jvilk
    That is the easiest way to do things.
    BrowserFS also has a number of other backends you could consider using, like the ZipFileSystem. With the ZipFileSystem, you can mount a zip file as a file system.

    https://github.com/jvilk/BrowserFS/blob/master/src/backend/ZipFS.ts#L593

    Example: (untested; just wrote right now)

    function makeZipFileSystem(cb) {
      var xhr = new XMLHttpRequest();
      xhr.open('GET', 'path/to/mynatives.zip');
      xhr.responseType = "arraybuffer";
      xhr.onload = function() {
        if (xhr.status === 200) {
          var buffer = BrowserFS.BFSRequire('buffer');
          var data = new buffer.Buffer(xhr.response);
          var zipfs = new BrowserFS.FileSystem.ZipFS(data);
          mfs.mount('/app', zipfs);
          cb();
        }
      };
      xhr.send();
    }
    @norzak hope that helps!
    John Vilk
    @jvilk
    @norzak also if you npm i -g browserfs you can run the make_xhrfs_index command from the command line
    norzak
    @norzak
    thank you very much for the detailed information
    norzak
    @norzak
    Hmm, if I use zipfile system, I wont need to create a listings.json then right? can a jar file directly be also mounted?
    or can we put jar files inside the zip file?
    I think I am expecting too muc out of this zip file system thing :).
    John Vilk
    @jvilk
    @norzak with zip file system no listings is needed. internally, DoppioJVM uses the zip file system to mount jars read from the file system.
    and yeah, you can put jars in the zip file
    I'd recommend that you do not mount a JAR file directly with ZipFS, since DoppioJVM will see it as a bunch of class files instead of a single JAR! Any meta information in the JAR will be ignored. Putting the jar file into a zip and mounting that is a better idea, even though it sounds insane.
    norzak
    @norzak
    @jvilk insane? you mean "we should avoid this" insane, or "it is a darn great idea" insane. :smile:
    John Vilk
    @jvilk

    @norzak it's a zip file in a zip file, so.... (as you may know, JAR files are just zip files)

    if you choose to do that, I'd recommend not compressing the JAR file, and only compressing the outer zip file. Otherwise, you'll pay the cost of decompression twice.

    norzak
    @norzak
    I see, thank you very much
    norzak
    @norzak
    I think I will go with mouthing jar because I do not need the meta information. By the way, is IE9 supported at all?
    norzak
    @norzak
    Hi again @jvilk what is the lowest allowed value for responsiveness?
    norzak
    @norzak
    What do you recommend for faster string concatenation? which method is using simple javascript concatenation?
    John Vilk
    @jvilk

    @norzak for some reason, Gitter just notified me of your messages. IE9 was once supported, but when its popularity waned, I dropped support to gain better performance.

    Since I'm using OpenJDK's string class, JVM strings do not map to JavaScript strings. JVM strings are arrays of bytes, and OpenJDK code handles concatenation and other tasks. Java-level tasks like string concatenation will use the StringBuilder class.

    norzak
    @norzak
    No problem. We have dropped IE9 and IE10 anyways. Thank you for the info on String concatenation.
    norzak
    @norzak
    How fast is the javascript to java String conversion? I am thinking about a custom string builder class for our project and want to use javascript native functions for slow methods such as numeric to string conversions. Would that make any sense performancewise?
    John Vilk
    @jvilk
    @norzak it should be O(n), where n is the number of characters in the string. It should be fast relative to JVM string operations. https://github.com/plasma-umass/doppio/blob/master/src/util.ts#L814
    norzak
    @norzak
    @jvilk Ok thanks a lot for the information. I think I will go with the custom string builder now.
    norzak
    @norzak
    @jvilk how do I return an array of strings from native method. Lets say I want use split method of javascript string for performance and want to return the result to Java. Is there an example for this kind of operations?
    'split(Ljava/lang/String;Ljava/lang/String;)[Ljava/lang/String;': function(thread, a,b) {return a.split(b);} will this really return string array?
    norzak
    @norzak
    Would this be also the case if the native method returns and array of integers or floats?
    John Vilk
    @jvilk
    @norzak whoa, java/lang/String isn't a JavaScript string, so .split won't work. And JVM arrays are JavaScript arrays wrapped by an object, so you'd need to use a helper method like this one: https://github.com/plasma-umass/doppio/blob/master/src/util.ts#L869 (grep around for uses in the natives to see examples)
    norzak
    @norzak
    :smile: thanks
    jezzarb94
    @jezzarb94
    hi
    so is there a basic tutroial on this to get things going
    John Vilk
    @jvilk
    Li Haoyi
    @lihaoyi
    Hi! This is a bit random, but since you guys implemented a JVM, does anyone here know anything about how invokeDynamic works?
    I'm implementing my own JVM, and am struggling a bit with it

    I was poking through your source code and felt a kindred spirit

    Further Java 8 progress. Almost to the point of invocation!
    And yes, these MemberName native methods are crazy whack.

    Tiago
    @Tiago-LA-Machado
    Hi, I have a game that runs with java native components. It has a lot of external files like png images and text files. Is there a way to upload my jar file with the external files and folders it requires to run? THX!!
    John Vilk
    @jvilk
    @lihaoyi sorry for the delayed response; I didn't see your question. The details escape me at present, as I added Java 8 support some time ago, but it was super helpful to look through the source code of JAMVM while working on Doppio's Java 8 support.
    Moritz Stückler
    @pReya
    Hey, this community has been quiet for a while ;) Hope someone is still around. Trying to execute Java Source code dynamically in the browser. Am I understanding it correctly, that I need to save my Java source code to a file within BrowserFS, and then call javac (like this https://github.com/plasma-umass/doppio/blob/master/classes/util/Javac.java), and then run the resulting class file output with a new Doppio Instance?
    Moritz Stückler
    @pReya
    Hey @jvilk any chance you could answer my last question?
    John Vilk
    @jvilk

    @pReya hey there! Sure, I can answer your question.

    Yes, all input files need to be in BrowserFS.

    It's true that you can use Doppio to run javac on a Java file in BrowserFS to produce a class file in BrowserFS, and then run that class file in Doppio.

    But it's also true that you can run javac on your own computer, put the resulting class file into BrowserFS, and run the class file in Doppio.

    You can also make a jar file, put it into BrowserFS, and run Doppio on the jar.

    Hope that helps!

    Moritz Stückler
    @pReya
    @jvilk Thanks for the answer! Another quick follow up: Is there a way to compile and run a java source file with one Doppio invocation? Or do I necessarily need to invoke Doppio twice (once for compiling, once for running)?
    Moritz Stückler
    @pReya
    Okay, I figured out that Java can load and execute classes programmatically, so I am optimistic I will be able to solve this. One last question: Can I only access BrowserFS within the BrowserFS.configure() callback? Everytime I call any fs. operation outside the callback, I get an error, that the BrowserFS filesystem hasn't been initialized.
    Mitch VanDuyn
    @catmando
    has anybody tried to get jruby to work?
    Moritz Stückler
    @pReya
    @catmando No, but running a JVM inside a browser, to run a Ruby interpreter sounds very excentric ;)
    I think Ruby can already be compiled to WebAssembly. That might be a better way to do it?
    Mitch VanDuyn
    @catmando
    @pReya yeah we use Opal (Ruby->JS transpiler) just always looking for better ways. Jruby runs ruby direclty on the JVM so performance is the same as Java.
    Moritz Stückler
    @pReya
    @jvilk I'm compiling and executing simple Hello-World-Style classes via Doppio. Do you have any reference for execution time? I'm getting between 15-20 seconds for compiling and executing a Hello World program (without the loading time for the runtime files). Do you have any ideas on how to speed this up? Or is this as good as it gets?
    puppeteer701vungle
    @puppeteer701vungle
    Hi guys
    I am new to BrowserFS, I have a question, it is probably a stupid one. Some context, I am building a previewer which will download a zip bundle and inside the zip it has all the content of the page. The idea that I have is, not to store the ZIPS and extract them on server, and then put the SRC of the iframe to that location, but to somehow use users/browsers storage to present the page in iframe. I see that browserfs allows me to save the zip files into ZipFS, and here is where the question lies, does browserfs save the file in the memory of the server(where previewer is running) or does it use clients/browsers devices memory?
    Jacob Andersen
    @simpleauthority
    Do I need to manually build and include doppio in, say, a VueJS project or is npm install doppiojvm sufficient?
    Jacob Andersen
    @simpleauthority
    apparently so. so far this is almost impossible to use in a SPA, it seems.