Browse Source

[performance] Remove synthetic access$ methods in transport package

Java compiler must generate synthetic access methods for private methods
and fields of the enclosing class if they are accessed from inner
classes and vice versa.

While invisible in the code, those synthetic access methods exist in the
bytecode and seem to produce some extra execution overhead at runtime
(compared with the direct access to this fields or methods), see
https://git.eclipse.org/r/58948/.

By removing the "private" access modifier from affected methods and
fields we help compiler to avoid generation of synthetic access methods
and hope to improve execution performance.

To validate changes, one can either use javap or use Bytecode Outline
plugin in Eclipse. In both cases one should look for "synthetic
access$<number>" methods at the end of the class and inner class files
in question - there should be none.

NB: don't mix this "synthetic access$" methods up with "public synthetic
bridge" methods generated to allow generic method override return types.

Change-Id: I0ebaeb2bc454cd8051b901addb102c1a6688688b
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
stable-4.2
Andrey Loskutov 9 years ago
parent
commit
df876d2e0f
  1. 12
      org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java
  2. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java
  3. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java
  4. 8
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java
  5. 18
      org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java
  6. 12
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java
  7. 10
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TrackingRefUpdate.java
  8. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java
  9. 4
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java
  10. 6
      org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java
  11. 10
      org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java
  12. 2
      org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java

12
org.eclipse.jgit/src/org/eclipse/jgit/transport/AmazonS3.java

@ -175,7 +175,7 @@ public class AmazonS3 {
private final String acl;
/** Maximum number of times to try an operation. */
private final int maxAttempts;
final int maxAttempts;
/** Encryption algorithm, may be a null instance that provides pass-through. */
private final WalkEncryption encryption;
@ -483,7 +483,7 @@ public class AmazonS3 {
return encryption.encrypt(new DigestOutputStream(buffer, md5));
}
private void putImpl(final String bucket, final String key,
void putImpl(final String bucket, final String key,
final byte[] csum, final TemporaryBuffer buf,
ProgressMonitor monitor, String monitorTask) throws IOException {
if (monitor == null)
@ -522,7 +522,7 @@ public class AmazonS3 {
throw maxAttempts(JGitText.get().s3ActionWriting, key);
}
private IOException error(final String action, final String key,
IOException error(final String action, final String key,
final HttpURLConnection c) throws IOException {
final IOException err = new IOException(MessageFormat.format(
JGitText.get().amazonS3ActionFailed, action, key,
@ -547,7 +547,7 @@ public class AmazonS3 {
return err;
}
private IOException maxAttempts(final String action, final String key) {
IOException maxAttempts(final String action, final String key) {
return new IOException(MessageFormat.format(
JGitText.get().amazonS3ActionFailedGivingUp, action, key,
Integer.valueOf(maxAttempts)));
@ -559,7 +559,7 @@ public class AmazonS3 {
return open(method, bucket, key, noArgs);
}
private HttpURLConnection open(final String method, final String bucket,
HttpURLConnection open(final String method, final String bucket,
final String key, final Map<String, String> args)
throws IOException {
final StringBuilder urlstr = new StringBuilder();
@ -596,7 +596,7 @@ public class AmazonS3 {
return c;
}
private void authorize(final HttpURLConnection c) throws IOException {
void authorize(final HttpURLConnection c) throws IOException {
final Map<String, List<String>> reqHdr = c.getRequestProperties();
final SortedMap<String, String> sigHdr = new TreeMap<String, String>();
for (final Map.Entry<String, List<String>> entry : reqHdr.entrySet()) {

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/Daemon.java

@ -79,7 +79,7 @@ public class Daemon {
private boolean run;
private Thread acceptThread;
Thread acceptThread;
private int timeout;
@ -87,9 +87,9 @@ public class Daemon {
private volatile RepositoryResolver<DaemonClient> repositoryResolver;
private volatile UploadPackFactory<DaemonClient> uploadPackFactory;
volatile UploadPackFactory<DaemonClient> uploadPackFactory;
private volatile ReceivePackFactory<DaemonClient> receivePackFactory;
volatile ReceivePackFactory<DaemonClient> receivePackFactory;
/** Configure a daemon to listen on any available network port. */
public Daemon() {
@ -326,7 +326,7 @@ public class Daemon {
}
}
private void startClient(final Socket s) {
void startClient(final Socket s) {
final DaemonClient dc = new DaemonClient(this);
final SocketAddress peer = s.getRemoteSocketAddress();

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/JschSession.java

@ -71,8 +71,8 @@ import com.jcraft.jsch.Session;
* to the constructor.
*/
public class JschSession implements RemoteSession {
private final Session sock;
private final URIish uri;
final Session sock;
final URIish uri;
/**
* Create a new session object by passing the real Jsch session and the URI
@ -119,7 +119,7 @@ public class JschSession implements RemoteSession {
private class JschProcess extends Process {
private ChannelExec channel;
private final int timeout;
final int timeout;
private InputStream inputStream;
@ -141,7 +141,7 @@ public class JschSession implements RemoteSession {
* @throws IOException
* on problems opening streams
*/
private JschProcess(final String commandName, int tms)
JschProcess(final String commandName, int tms)
throws TransportException, IOException {
timeout = tms;
try {

8
org.eclipse.jgit/src/org/eclipse/jgit/transport/PackParser.java

@ -122,14 +122,14 @@ public abstract class PackParser {
private InputStream in;
private byte[] buf;
byte[] buf;
/** Position in the input stream of {@code buf[0]}. */
private long bBase;
private int bOffset;
private int bAvail;
int bAvail;
private ObjectChecker objCheck;
@ -1141,13 +1141,13 @@ public abstract class PackParser {
}
// Consume cnt bytes from the buffer.
private void use(final int cnt) {
void use(final int cnt) {
bOffset += cnt;
bAvail -= cnt;
}
// Ensure at least need bytes are available in in {@link #buf}.
private int fill(final Source src, final int need) throws IOException {
int fill(final Source src, final int need) throws IOException {
while (bAvail < need) {
int next = bOffset + bAvail;
int free = buf.length - next;

18
org.eclipse.jgit/src/org/eclipse/jgit/transport/PushCertificateStore.java

@ -107,11 +107,11 @@ public class PushCertificateStore implements AutoCloseable {
Constants.R_REFS + "meta/push-certs"; //$NON-NLS-1$
private static class PendingCert {
private PushCertificate cert;
private PersonIdent ident;
private Collection<ReceiveCommand> matching;
PushCertificate cert;
PersonIdent ident;
Collection<ReceiveCommand> matching;
private PendingCert(PushCertificate cert, PersonIdent ident,
PendingCert(PushCertificate cert, PersonIdent ident,
Collection<ReceiveCommand> matching) {
this.cert = cert;
this.ident = ident;
@ -121,8 +121,8 @@ public class PushCertificateStore implements AutoCloseable {
private final Repository db;
private final List<PendingCert> pending;
private ObjectReader reader;
private RevCommit commit;
ObjectReader reader;
RevCommit commit;
/**
* Create a new store backed by the given repository.
@ -270,7 +270,7 @@ public class PushCertificateStore implements AutoCloseable {
};
}
private void load() throws IOException {
void load() throws IOException {
close();
reader = db.newObjectReader();
Ref ref = db.getRefDatabase().exactRef(REF_NAME);
@ -283,7 +283,7 @@ public class PushCertificateStore implements AutoCloseable {
}
}
private static PushCertificate read(TreeWalk tw) throws IOException {
static PushCertificate read(TreeWalk tw) throws IOException {
if (tw == null || (tw.getRawMode(0) & TYPE_FILE) != TYPE_FILE) {
return null;
}
@ -532,7 +532,7 @@ public class PushCertificateStore implements AutoCloseable {
return TreeWalk.forPath(reader, pathName(refName), commit.getTree());
}
private static String pathName(String refName) {
static String pathName(String refName) {
return refName + "@{cert}"; //$NON-NLS-1$
}

12
org.eclipse.jgit/src/org/eclipse/jgit/transport/TestProtocol.java

@ -78,17 +78,17 @@ public class TestProtocol<C> extends TransportProtocol {
private static final String SCHEME = "test"; //$NON-NLS-1$
private class Handle {
private final C req;
private final Repository remote;
final C req;
final Repository remote;
private Handle(C req, Repository remote) {
Handle(C req, Repository remote) {
this.req = req;
this.remote = remote;
}
}
private final UploadPackFactory<C> uploadPackFactory;
private final ReceivePackFactory<C> receivePackFactory;
final UploadPackFactory<C> uploadPackFactory;
final ReceivePackFactory<C> receivePackFactory;
private final HashMap<URIish, Handle> handles;
/**
@ -165,7 +165,7 @@ public class TestProtocol<C> extends TransportProtocol {
private class TransportInternal extends Transport implements PackTransport {
private final Handle handle;
private TransportInternal(Repository local, URIish uri, Handle handle) {
TransportInternal(Repository local, URIish uri, Handle handle) {
super(local, uri);
this.handle = handle;
}

10
org.eclipse.jgit/src/org/eclipse/jgit/transport/TrackingRefUpdate.java

@ -52,10 +52,10 @@ import org.eclipse.jgit.lib.RefUpdate;
/** Update of a locally stored tracking branch. */
public class TrackingRefUpdate {
private final String remoteName;
private final String localName;
private boolean forceUpdate;
private ObjectId oldObjectId;
private ObjectId newObjectId;
final String localName;
boolean forceUpdate;
ObjectId oldObjectId;
ObjectId newObjectId;
private RefUpdate.Result result;
private ReceiveCommand cmd;
@ -142,7 +142,7 @@ public class TrackingRefUpdate {
}
final class Command extends ReceiveCommand {
private Command() {
Command() {
super(oldObjectId, newObjectId, localName);
}

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransferConfig.java

@ -72,13 +72,13 @@ public class TransferConfig {
private final boolean safeForMacOS;
private final boolean allowTipSha1InWant;
private final boolean allowReachableSha1InWant;
private final String[] hideRefs;
final String[] hideRefs;
TransferConfig(final Repository db) {
this(db.getConfig());
}
private TransferConfig(final Config rc) {
TransferConfig(final Config rc) {
checkReceivedObjects = rc.getBoolean(
"fetch", "fsckobjects", //$NON-NLS-1$ //$NON-NLS-2$
rc.getBoolean("transfer", "fsckobjects", false)); //$NON-NLS-1$ //$NON-NLS-2$

4
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportAmazonS3.java

@ -125,10 +125,10 @@ public class TransportAmazonS3 extends HttpTransport implements WalkTransport {
};
/** User information necessary to connect to S3. */
private final AmazonS3 s3;
final AmazonS3 s3;
/** Bucket the remote repository is stored in. */
private final String bucket;
final String bucket;
/**
* Key prefix which all objects related to the repository start with.

6
org.eclipse.jgit/src/org/eclipse/jgit/transport/TransportHttp.java

@ -218,16 +218,16 @@ public class TransportHttp extends HttpTransport implements WalkTransport,
sslVerify = rc.getBoolean("http", "sslVerify", true); //$NON-NLS-1$ //$NON-NLS-2$
}
private HttpConfig() {
HttpConfig() {
this(new Config());
}
}
private final URL baseUrl;
final URL baseUrl;
private final URL objectsUrl;
private final HttpConfig http;
final HttpConfig http;
private final ProxySelector proxySelector;

10
org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkFetchConnection.java

@ -115,10 +115,10 @@ import org.eclipse.jgit.util.FileUtils;
*/
class WalkFetchConnection extends BaseFetchConnection {
/** The repository this transport fetches into, or pushes out of. */
private final Repository local;
final Repository local;
/** If not null the validator for received objects. */
private final ObjectChecker objCheck;
final ObjectChecker objCheck;
/**
* List of all remote repositories we may need to get objects out of.
@ -180,12 +180,12 @@ class WalkFetchConnection extends BaseFetchConnection {
*/
private final HashMap<ObjectId, List<Throwable>> fetchErrors;
private String lockMessage;
String lockMessage;
private final List<PackLock> packLocks;
final List<PackLock> packLocks;
/** Inserter to write objects onto {@link #local}. */
private final ObjectInserter inserter;
final ObjectInserter inserter;
/** Inserter to read objects from {@link #local}. */
private final ObjectReader reader;

2
org.eclipse.jgit/src/org/eclipse/jgit/transport/WalkPushConnection.java

@ -103,7 +103,7 @@ class WalkPushConnection extends BaseConnection implements PushConnection {
private final URIish uri;
/** Database connection to the remote repository. */
private final WalkRemoteObjectDatabase dest;
final WalkRemoteObjectDatabase dest;
/** The configured transport we were constructed by. */
private final Transport transport;

Loading…
Cancel
Save