Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of profile (compact1, compact2, compact 3) in Java API documentation?

Tags:

java

javadoc

Recently I've got to know that there are annotations like compact1, compact2, compact3 for some classes, in Java 8 API documentation.

Those seem to be called profile, as you can see on the overview page. (See the below images.) The profile, compact1, compact2, compact3 are not appear in Java 6 or 7 API documentation.

What do they mean in Java 8 API doc?

enter image description here

enter image description here

like image 858
ntalbs Avatar asked Dec 24 '14 07:12

ntalbs


People also ask

What is a Compact profile?

A compact profile (or simply profile) is a subset of the full Java SE Platform API. Because they have smaller storage footprints, profiles can enable many Java applications to run on resource-constrained devices.

What is compact in Java?

A compact profile is a subset of the full Java SE Platform API. Because they have a smaller storage footprint, compact profiles can enable many Java applications to run on resource-constrained devices.


1 Answers

Compact profiles are subsets of the full Java platform APIs, to allow running with a smaller JRE. Many programs (especially in embedded environments) don't need libraries like Swing or CORBA -- they're just wasted space. From the Oracle Java SE Embedded 8 Compact Profiles Overview:

A compact profile is a subset of the full Java SE Platform API. Because they have a smaller storage footprint, compact profiles can enable many Java applications to run on resource-constrained devices. Choosing a compact profile that closely matches an application's functional needs minimizes the storage devoted to unused functions. There are new embedded developer tools in Java SE Embedded 8 including jrecreate and jdeps, which allow a developer to customize the Compact Profile runtime environment for a platform, and to find the Compact Profile dependencies for analysis during platform development.

Compact profiles address API choices only; they are unrelated to the Java virtual machine, the language proper, or tools. So, care must be taken to match the Java virtual machine supported functionality with the API support needed.

That page also lists the contents of each profile. The currently defined profiles all have a subset relationship (compact2 includes compact1, compact 3 includes compact2).

Use the -profile option to javac to compile against a profile. javac will complain if the source uses an API not available in the profile, like in this example from the javac doc:

./javac -profile compact1 Paint.java Paint.java:5: error: Applet is not available in profile 'compact1' import java.applet.Applet; 
like image 138
Jeffrey Bosboom Avatar answered Oct 17 '22 04:10

Jeffrey Bosboom