{"id":17945334,"url":"https://github.com/westnordost/java-to-as3","last_synced_at":"2025-04-03T14:40:35.527Z","repository":{"id":8900070,"uuid":"10622454","full_name":"westnordost/java-to-as3","owner":"westnordost","description":"A Java to AS3 compiler","archived":false,"fork":false,"pushed_at":"2013-06-12T13:54:20.000Z","size":233,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T03:26:51.159Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/westnordost.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-11T13:49:26.000Z","updated_at":"2024-01-13T01:50:40.000Z","dependencies_parsed_at":"2022-08-29T19:00:35.518Z","dependency_job_id":null,"html_url":"https://github.com/westnordost/java-to-as3","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westnordost%2Fjava-to-as3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westnordost%2Fjava-to-as3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westnordost%2Fjava-to-as3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/westnordost%2Fjava-to-as3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/westnordost","download_url":"https://codeload.github.com/westnordost/java-to-as3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247022117,"owners_count":20870724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-29T06:43:04.468Z","updated_at":"2025-04-03T14:40:35.499Z","avatar_url":"https://github.com/westnordost.png","language":"Java","readme":"Java to AS3 Compiler v1.0.9\n===========================\n\nThis software was developed by [Sojo Studios, Inc.](http://www.sojostudios.com/)\nPlease visit the [project's home page](https://github.com/Sojo-Studios/java-to-as3).\n\nThis is a tool that will take Java 1.5 source code and make a best-effort translation of that \ncode into AS3 code. The resulting AS3 code can then be compiled into a SWF or SWC using\n[Adobe's Flex SDK](http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK).\n\nThe compiler uses the [javaparser](http://code.google.com/p/javaparser/) library to \nconstruct an Abstract Syntax Tree from the input Java code. There are then two passes \nmade over the tree. The first is a `mutation` pass where incompatible nodes are replaced \nwith compatible nodes. The second is a `dump` pass, where the AS3 source code is assembled\ninto a string of text. \n\n\nFeatures\n--------\nThe major features of this compiler revolve around the ability to perform basic mutations\nfrom Java-specific classes into AS3 equivalents. The three major targets are:\n\n* Arrays\n* Vectors\n* Dictionaries\n\nThe use of these classes is fundamentally different within the context of AS3, but there\nare obviously Java counterparts:\n\n* Arrays and Lists\n* Lists / Collections\n* Maps\n\nThe default mutations include:\n\n* The conversion of any array, typed as \"L[Class]\" in Java, into an AS3 Array\n* The conversion of some Lists into AS3 Vectors, including template-typing\n* The conversion of some Maps into AS3 Dictionaries\n\nThere is also the ability to specify any additional Class type as a something that needs to \nbe converted to one of the above. This is useful if you extend a Map or List.\n\nThe additional basic features provide some utilities for conversions between compatible classes\nthat do not need mutations.\n\n* Forcing a class to extend Sprite or MovieClip (forceSprite, forceMovieClip)\n* Regex matching package names and converting them (packageToPackage)\n* Regex matching imports and converting them (importsToImports)\n* Regex matching class names and converting them (classesToClasses)\n* Ability to completely ignore regex matched imports such as `java.*` (importsToIgnore)\n* Ability to force additional imports (forcedImports)\n* Ability to specify additional classes to be converted to Arrays (classesToArrays)\n* Ability to specify additional classes to be converted to Vectors (classesToVectors)\n* Ability to specify additional classes to be converted to Dictionaries (classesToDictionaries)\n\n\nLimitations\n-----------\nBecause this compiler only parses one file at a time, it does not do type checking, and does \nnot track typing information from imports. This means that if you use an external function that\nreturns a type that needs to be mutated, such as a string, the compiler will not be able to\ndetect the need for a mutation.\n\nFor example: \n\n```java\nif(ExternalClass.getAString().equals(\"x\"))\n```\n\nWill not be properly translated into\n\n```actionscript\nif(ExternalClass.getAString() == \"x\")\n```\n\nThe workaround for these typing situations is to store the value in a local variable first. This \nmakes the code more terse, but it does work.\n\n```java\nString myVal = ExternalClass.getAString();\nif(myVal.equals(\"x\"))\n```\n\nWill be properly translated into\n\n```actionscript\nvar myVal:String = ExternalClass.getAString();\nif(myVal == \"x\")\n```\n\n\nUsing With Ant\n--------------\n\nIn addition to the `sojo-java-to-as3` jar, you will need to have `log4j` and `javaparser` included \nin the classpath to use this task in Ant.\n\n```xml\n\u003ctaskdef name=\"javaToAs3\" classname=\"com.sojostudios.as3.ant.JavaToAS3Task\"\u003e\n\t\u003cclasspath refid=\"some.path\" /\u003e\n\u003c/taskdef\u003e\n\u003ctarget name=\"compile\"\u003e\n\t\u003cjavaToAs3 includeDefaultMutations=\"true\"\u003e\n\t\t\u003csourceTarget src=\"MyClass.java\" dst=\"MyClass.as\" forceMovieClip=\"true\" /\u003e\n \t\t\u003csourceTarget src=\"MyHelperClass.java\" dst=\"MyHelperClass.as\" /\u003e\n\t\u003c/javaToAs3\u003e\n\u003c/target\u003e\n```\n\n\nIncluding with Ivy\n------------------\n\nYou will need to add a `url` entry to your repositories list in your \n[Ivy settings file](http://ant.apache.org/ivy/history/latest-milestone/use/settings.html).\nExample settings file:\n\n```xml\n\u003civysettings\u003e\n        \u003csettings defaultResolver=\"ibiblio\"/\u003e\n        \u003cresolvers\u003e\n                \u003cibiblio name=\"ibiblio\" m2compatible=\"true\"/\u003e\n                \u003curl name=\"sojo-studios.github.com\"\u003e\n\t\t\t\t\t\u003civy pattern=\"http://sojo-studios.github.com/repo/[module]/[revision]/ivy.xml\" /\u003e\n\t\t\t\t\t\u003cartifact pattern=\"http://sojo-studios.github.com/repo/[module]/[revision]/[artifact]-[revision].[ext]\" /\u003e\n\t\t\t\t\u003c/url\u003e\n        \u003c/resolvers\u003e\n        \u003cmodules\u003e\n                \u003cmodule organisation=\"com.sojostudios\" name=\".*\" resolver=\"sojo-studios.github.com\" /\u003e\n        \u003c/modules\u003e\n\u003c/ivysettings\u003e\n```\n\nYou then need to add a dependency for `sojo-java-to-as3` to your `ivy.xml` file that points to `master`.\n\n```xml\n\u003cconfigurations\u003e\n\t\u003cconf name=\"compile\" visibility=\"public\" description=\"libraries used during compilation.\"/\u003e\n\t\u003cconf name=\"runtime\" visibility=\"public\" description=\"libraries used during runtime.\" extends=\"compile\"/\u003e\n\u003c/configurations\u003e\n\u003cdependencies\u003e\n\t\u003cdependency org=\"com.sojostudios\" name=\"sojo-java-to-as3\" rev=\"1.0.5\" conf=\"compile-\u003emaster(*);runtime-\u003edefault\"/\u003e\n\u003c/dependencies\u003e\n```\n\nAlso, don't forget to load your Ivy settings file in your Ant buildfile. Example assuming file is `ivysettings.xml` \nin the root project build directory:\n\n```xml\n\u003civy:settings file=\"ivysettings.xml\" /\u003e\n```\n\nThen add a task to your Ant buildfile to resolve dependencies:\n\n```xml\n\u003ctarget name=\"resolve\" description=\"resolve dependencies\"\u003e\n\t\u003civy:retrieve conf=\"compile\"/\u003e\n\u003c/target\u003e\n```\n\n\nBuilding from Source\n--------------------\n\nYou will need Ant and Ivy installed to build this project. Once they are installed, just run `ant` in the\nroot project directory and will create a .jar file in the jar/ directory.\n\n\nChangelog\n---------\nv1.0.12\n* fixed a bug where cast expressions were being ignored in variable declarations during mutation pass\n\nv1.0.11\n* added ability to modify mutation output class names\n\nv1.0.10\n* fixed an issue with scientific notation on doubles, where E was removed from the output string\n\nv1.0.9\n* added support for loglevel attribute in ant task\n\nv1.0.8\n* added support for extending array/vector/dictionary types\n\nv1.0.7\n* fixed scoping/mutation problem with class field declarations\n\nv1.0.6a\n* removed comments for Map declarations, Map\u0026lt;a,Map\u0026lt;b,c\u0026gt;\u0026gt; were creating syntax errors\n\nv1.0.6\n* added all standard Collection and Map classes for conversion\n\nv1.0.5\n* initial public release\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestnordost%2Fjava-to-as3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwestnordost%2Fjava-to-as3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwestnordost%2Fjava-to-as3/lists"}