Gum

Gum - A thin wrapper around Apple's Mac-specific Java libraries to allow code to compile on other platforms without redistributing Apple's jar.

License

License

GroupId

GroupId

org.trypticon.gum
ArtifactId

ArtifactId

gum
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

Gum
Gum - A thin wrapper around Apple's Mac-specific Java libraries to allow code to compile on other platforms without redistributing Apple's jar.
Project URL

Project URL

https://github.com/trejkaz/gum
Source Code Management

Source Code Management

https://github.com/trejkaz/gum

Download gum

How to add to project

<!-- https://jarcasting.com/artifacts/org.trypticon.gum/gum/ -->
<dependency>
    <groupId>org.trypticon.gum</groupId>
    <artifactId>gum</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.trypticon.gum/gum/
implementation 'org.trypticon.gum:gum:0.1'
// https://jarcasting.com/artifacts/org.trypticon.gum/gum/
implementation ("org.trypticon.gum:gum:0.1")
'org.trypticon.gum:gum:jar:0.1'
<dependency org="org.trypticon.gum" name="gum" rev="0.1">
  <artifact name="gum" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.trypticon.gum', module='gum', version='0.1')
)
libraryDependencies += "org.trypticon.gum" % "gum" % "0.1"
[org.trypticon.gum/gum "0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Gum - A simple wrapper around the com.apple classes in Java to allow your code to compile on non-Mac systems.

Copyright (C) 2013 Trejkaz, Gum Project

WHY WRAP IT

If you want your application to integrate better with Mac OS X, you are recommended to use the com.apple extensions where relevant.

However, if you also want to run your application on non-Mac systems, any attempts to load com.apple classes will bomb your application out with a NoClassDefFoundError. This will be the case until Oracle start shipping these classes with the JRE (at which point, wrappers like this will become unnecessary.)

APPROACH

There have been numerous libraries to do this in the past (e.g. MRJAdapter, Macify) and mine isn't special in any particular way.

I have just tried to wrap all the current APIs. Where possible, I have changed the API slightly to improve type safety (e.g., replacing magic numbers with enum values, or replacing String file paths with File.) Since this library has Java 7 as the minimum version, I have also removed any deprecated APIs as there is very little point to keeping them.

Some wrapper libraries use reflection to do the job. Gum does not - it uses delegate classes to call the com.apple classes directly. This is perfectly safe - as long as your application isn't accessing any of the classes inside packages named "internal", the code which depends on com.apple classes should never execute. (If it does, it's probably a bug.)

USING

com.trypticon.gum.MacFactory is the main entry point and you can get to everything else from there.

Documentation is severely lacking on my side, but the methods more or less correspond one-to-one with their counterparts in com.apple, so it is possible to consult the com.apple documentation to fill in the gaps.

BUILDING

You'll need a Java build environment. I'm developing this on Java 7 at the moment. Additionally, the code will only compile on Mac OS X.

You'll also need Ant. All the other dependencies should be bundled. If something is missing, prod me to fix it.

To build, execute ant in the top directory. The jar file will appear in build/.

Versions

Version
0.1