code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public void interrupt() { synchronized(nativeThread) { synchronized (interruptActions) { for (int i = interruptActions.size() - 1; i >= 0; i--) { interruptActions.get(i).run(); } } synchronized (IOBlockerLock) { Interruptible b = IOBlocker; if (b != null) { b.interrupt(this); } } if (interrupted) { return; // No further action needed. } interrupted = true; if (blocker != null) { synchronized(blocker) { blocker.notify(); } } } }
Posts an interrupt request to this {@code Thread}. Unless the caller is the {@link #currentThread()}, the method {@code checkAccess()} is called for the installed {@code SecurityManager}, if any. This may result in a {@code SecurityException} being thrown. The further behavior depends on the state of this {@code Thread}: <ul> <li> {@code Thread}s blocked in one of {@code Object}'s {@code wait()} methods or one of {@code Thread}'s {@code join()} or {@code sleep()} methods will be woken up, their interrupt status will be cleared, and they receive an {@link InterruptedException}. <li> {@code Thread}s blocked in an I/O operation of an {@link java.nio.channels.InterruptibleChannel} will have their interrupt status set and receive an {@link java.nio.channels.ClosedByInterruptException}. Also, the channel will be closed. <li> {@code Thread}s blocked in a {@link java.nio.channels.Selector} will have their interrupt status set and return immediately. They don't receive an exception in this case. <ul> @throws SecurityException if <code>checkAccess()</code> fails with a SecurityException @see java.lang.SecurityException @see java.lang.SecurityManager @see Thread#interrupted @see Thread#isInterrupted
Thread::interrupt
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public boolean isInterrupted() { return interrupted; }
Returns a <code>boolean</code> indicating whether the receiver has a pending interrupt request (<code>true</code>) or not ( <code>false</code>) @return a <code>boolean</code> indicating the interrupt status @see Thread#interrupt @see Thread#interrupted
Thread::isInterrupted
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public final void join() throws InterruptedException { if (!isAlive()) { return; } Object lock = currentThread().nativeThread; synchronized (lock) { while (isAlive()) { lock.wait(POLL_INTERVAL); } } }
Blocks the current Thread (<code>Thread.currentThread()</code>) until the receiver finishes its execution and dies. @throws InterruptedException if <code>interrupt()</code> was called for the receiver while it was in the <code>join()</code> call @see Object#notifyAll @see java.lang.ThreadDeath
Thread::join
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public final void join(long millis) throws InterruptedException { join(millis, 0); }
Blocks the current Thread (<code>Thread.currentThread()</code>) until the receiver finishes its execution and dies or the specified timeout expires, whatever happens first. @param millis The maximum time to wait (in milliseconds). @throws InterruptedException if <code>interrupt()</code> was called for the receiver while it was in the <code>join()</code> call @see Object#notifyAll @see java.lang.ThreadDeath
Thread::join
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public final void join(long millis, int nanos) throws InterruptedException { if (millis < 0 || nanos < 0 || nanos >= NANOS_PER_MILLI) { throw new IllegalArgumentException("bad timeout: millis=" + millis + ",nanos=" + nanos); } // avoid overflow: if total > 292,277 years, just wait forever boolean overflow = millis >= (Long.MAX_VALUE - nanos) / NANOS_PER_MILLI; boolean forever = (millis | nanos) == 0; if (forever | overflow) { join(); return; } if (!isAlive()) { return; } Object lock = currentThread().nativeThread; synchronized (lock) { if (!isAlive()) { return; } // guaranteed not to overflow long nanosToWait = millis * NANOS_PER_MILLI + nanos; // wait until this thread completes or the timeout has elapsed long start = System.nanoTime(); while (true) { if (millis > POLL_INTERVAL) { lock.wait(POLL_INTERVAL); } else { lock.wait(millis, nanos); } if (!isAlive()) { break; } long nanosElapsed = System.nanoTime() - start; long nanosRemaining = nanosToWait - nanosElapsed; if (nanosRemaining <= 0) { break; } millis = nanosRemaining / NANOS_PER_MILLI; nanos = (int) (nanosRemaining - millis * NANOS_PER_MILLI); } } }
Blocks the current Thread (<code>Thread.currentThread()</code>) until the receiver finishes its execution and dies or the specified timeout expires, whatever happens first. @param millis The maximum time to wait (in milliseconds). @param nanos Extra nanosecond precision @throws InterruptedException if <code>interrupt()</code> was called for the receiver while it was in the <code>join()</code> call @see Object#notifyAll @see java.lang.ThreadDeath
Thread::join
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public ClassLoader getContextClassLoader() { return contextClassLoader != null ? contextClassLoader : ClassLoader.getSystemClassLoader(); }
Returns the context ClassLoader for this Thread. @return ClassLoader The context ClassLoader @see java.lang.ClassLoader
Thread::getContextClassLoader
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public static UncaughtExceptionHandler getDefaultUncaughtExceptionHandler() { return defaultUncaughtHandler; }
Returns the default exception handler that's executed when uncaught exception terminates a thread. @return an {@link UncaughtExceptionHandler} or <code>null</code> if none exists.
Thread::getDefaultUncaughtExceptionHandler
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler handler) { Thread.defaultUncaughtHandler = handler; }
Sets the default uncaught exception handler. This handler is invoked in case any Thread dies due to an unhandled exception. @param handler The handler to set or null.
Thread::setDefaultUncaughtExceptionHandler
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public UncaughtExceptionHandler getUncaughtExceptionHandler() { UncaughtExceptionHandler h = uncaughtExceptionHandler; return h != null ? h : threadGroup; }
Returns the handler invoked when this thread abruptly terminates due to an uncaught exception. If this thread has not had an uncaught exception handler explicitly set then this thread's <tt>ThreadGroup</tt> object is returned, unless this thread has terminated, in which case <tt>null</tt> is returned. @since 1.5
Thread::getUncaughtExceptionHandler
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) { checkAccess(); uncaughtExceptionHandler = eh; }
Set the handler invoked when this thread abruptly terminates due to an uncaught exception. <p>A thread can take full control of how it responds to uncaught exceptions by having its uncaught exception handler explicitly set. If no such handler is set then the thread's <tt>ThreadGroup</tt> object acts as its handler. @param eh the object to use as this thread's uncaught exception handler. If <tt>null</tt> then this thread has no explicit handler. @throws SecurityException if the current thread is not allowed to modify this thread. @see #setDefaultUncaughtExceptionHandler @see ThreadGroup#uncaughtException @since 1.5
Thread::setUncaughtExceptionHandler
java
google/j2objc
jre_emul/Classes/java/lang/Thread.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Thread.java
Apache-2.0
public static SecurityManager getSecurityManager() { return null; }
Returns null. Android does not use {@code SecurityManager}. This method is only provided for source compatibility. @return null
System::getSecurityManager
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static String lineSeparator() { return "\n"; // Always return OSX/iOS value. }
Returns the system's line separator. @since 1.7
System::lineSeparator
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void load(String pathName) { Runtime.getRuntime().load(pathName); }
See {@link Runtime#load}.
System::load
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void loadLibrary(String libName) { Runtime.getRuntime().loadLibrary(libName); }
See {@link Runtime#loadLibrary}.
System::loadLibrary
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void runFinalization() {}
No-op on iOS, since it doesn't use garbage collection.
System::runFinalization
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void runFinalizersOnExit(boolean b) {}
No-op on iOS, since it doesn't use garbage collection.
System::runFinalizersOnExit
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static Console console() { return Console.getConsole(); }
Returns the {@link java.io.Console} associated with this VM, or null. Not all VMs will have an associated console. A console is typically only available for programs run from the command line. @since 1.6
System::console
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logE(String message) { log(Level.SEVERE, message, null); }
@hide internal use only
System::logE
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logE(String message, Throwable th) { log(Level.SEVERE, message, th); }
@hide internal use only
System::logE
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logI(String message) { log(Level.INFO, message, null); }
@hide internal use only
System::logI
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logI(String message, Throwable th) { log(Level.INFO, message, th); }
@hide internal use only
System::logI
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logW(String message) { log(Level.WARNING, message, null); }
@hide internal use only
System::logW
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static void logW(String message, Throwable th) { log(Level.WARNING, message, th); }
@hide internal use only
System::logW
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public static Channel inheritedChannel() throws IOException { // j2objc: Android always returns null, so avoid calling // SelectorProvider to keep library subsets separate. return null; }
Returns the channel inherited from the entity that created this Java virtual machine. <p> This method returns the channel obtained by invoking the {@link java.nio.channels.spi.SelectorProvider#inheritedChannel inheritedChannel} method of the system-wide default {@link java.nio.channels.spi.SelectorProvider} object. </p> <p> In addition to the network-oriented channels described in {@link java.nio.channels.spi.SelectorProvider#inheritedChannel inheritedChannel}, this method may return other kinds of channels in the future. @return The inherited channel, if any, otherwise <tt>null</tt>. @throws IOException If an I/O error occurs @throws SecurityException If a security manager is present and it does not permit access to the channel. @since 1.5
System::inheritedChannel
java
google/j2objc
jre_emul/Classes/java/lang/System.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/System.java
Apache-2.0
public void load(String absolutePath) {}
No-op on iOS, since all code must be linked into app bundle.
Runtime::load
java
google/j2objc
jre_emul/Classes/java/lang/Runtime.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Runtime.java
Apache-2.0
public void loadLibrary(String nickname) {}
No-op on iOS, since all code must be linked into app bundle.
Runtime::loadLibrary
java
google/j2objc
jre_emul/Classes/java/lang/Runtime.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Runtime.java
Apache-2.0
public void runFinalization() {}
No-op on iOS, since it doesn't use garbage collection.
Runtime::runFinalization
java
google/j2objc
jre_emul/Classes/java/lang/Runtime.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Runtime.java
Apache-2.0
public void traceInstructions(boolean enable) {}
No-op on iOS.
Runtime::traceInstructions
java
google/j2objc
jre_emul/Classes/java/lang/Runtime.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Runtime.java
Apache-2.0
public void traceMethodCalls(boolean enable) {}
No-op on iOS.
Runtime::traceMethodCalls
java
google/j2objc
jre_emul/Classes/java/lang/Runtime.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/java/lang/Runtime.java
Apache-2.0
public static FileSystemProvider create() { return new MacOSXFileSystemProvider(); }
Returns the default FileSystemProvider.
DefaultFileSystemProvider::create
java
google/j2objc
jre_emul/Classes/sun/nio/fs/DefaultFileSystemProvider.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/sun/nio/fs/DefaultFileSystemProvider.java
Apache-2.0
public LibraryNotLinkedError( String functionalName, String libraryName, String dependencyClassName) { super( String.format( EXCEPTION_MESSAGE, functionalName, libraryName, dependencyClassName, dependencyClassName)); }
Create a new LibraryNotLinkedException. @param functionalName the Java functionality that was requested @param libraryName the name of the J2ObjC JRE library that was not linked @param dependencyClassName the class to statically reference to force linking
LibraryNotLinkedError::LibraryNotLinkedError
java
google/j2objc
jre_emul/Classes/com/google/j2objc/LibraryNotLinkedError.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/LibraryNotLinkedError.java
Apache-2.0
public LibraryNotLinkedError( String functionalName, String libraryName, String dependencyClassName, String addedText, Object... args) { super( String.format( EXCEPTION_MESSAGE, functionalName, libraryName, dependencyClassName, dependencyClassName) + '\n' + String.format(addedText, args)); }
Create a new LibraryNotLinkedException. @param functionalName the Java functionality that was requested @param libraryName the name of the J2ObjC JRE library that was not linked @param dependencyClassName the class to statically reference to force linking @param addedText text to be appended to the exception message @param args any values to be used when formatting the addedText string.
LibraryNotLinkedError::LibraryNotLinkedError
java
google/j2objc
jre_emul/Classes/com/google/j2objc/LibraryNotLinkedError.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/LibraryNotLinkedError.java
Apache-2.0
public ReflectionStrippedError(Class<?> cls) { super(cls.getName() + EXCEPTION_MESSAGE); }
Create a new ReflectionStrippedError.
ReflectionStrippedError::ReflectionStrippedError
java
google/j2objc
jre_emul/Classes/com/google/j2objc/ReflectionStrippedError.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/ReflectionStrippedError.java
Apache-2.0
public Object getNSError() { return nsError; }
Returns the native NSError instance.
NSErrorException::getNSError
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/NSErrorException.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/NSErrorException.java
Apache-2.0
private void loadRequestCookies() throws IOException { CookieHandler cookieHandler = CookieHandler.getDefault(); if (cookieHandler != null) { try { URI uri = getURL().toURI(); Map<String, List<String>> cookieHeaders = cookieHandler.get(uri, getHeaderFieldsDoNotForceResponse()); for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) { String key = entry.getKey(); if (("Cookie".equalsIgnoreCase(key) || "Cookie2".equalsIgnoreCase(key)) && !entry.getValue().isEmpty()) { List<String> cookies = entry.getValue(); StringBuilder sb = new StringBuilder(); for (int i = 0, size = cookies.size(); i < size; i++) { if (i > 0) { sb.append("; "); } sb.append(cookies.get(i)); } setHeader(key, sb.toString()); } } } catch (URISyntaxException e) { throw new IOException(e); } } }
Add any cookies for this URI to the request headers.
IosHttpURLConnection::loadRequestCookies
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java
Apache-2.0
private void saveResponseCookies() throws IOException { saveResponseCookies(getURL(), getHeaderFieldsDoNotForceResponse()); }
Store any returned cookies.
IosHttpURLConnection::saveResponseCookies
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/IosHttpURLConnection.java
Apache-2.0
DataEnqueuedInputStream(long timeoutMillis) { this.timeoutMillis = timeoutMillis; }
Create an InputStream with timeout. @param timeoutMillis timeout in millis. If it's negative, the reads will never time out.
DataEnqueuedInputStream::DataEnqueuedInputStream
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
Apache-2.0
void offerData(byte[] chunk) { if (chunk == null || chunk.length == 0) { throw new IllegalArgumentException("chunk must have at least one byte of data"); } if (closed) { return; } // Since this is an unbounded queue, offer() always succeeds. In addition, we don't make a copy // of the chunk, as the data source (NSURLSessionDataTask) does not reuse the underlying byte // array of a chunk when the chunk is alive. queue.offer(chunk); }
Create an InputStream with timeout. @param timeoutMillis timeout in millis. If it's negative, the reads will never time out. DataEnqueuedInputStream(long timeoutMillis) { this.timeoutMillis = timeoutMillis; } /** Offers a chunk of data to the queue.
DataEnqueuedInputStream::offerData
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
Apache-2.0
void endOffering() { endOffering(null); }
Signals that no more data is available without errors. It is ok to call this multiple times.
DataEnqueuedInputStream::endOffering
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
Apache-2.0
void endOffering(IOException exception) { if (closed) { return; } // closed should never be set by this method--only the polling side should do it, as it means // that the CLOSED marker has been encountered. if (this.exception == null) { this.exception = exception; } // Since this is an unbounded queue, offer() always succeeds. queue.offer(CLOSED); }
Signals that no more data is available without errors. It is ok to call this multiple times. void endOffering() { endOffering(null); } /** Signals that no more data is available and an exception should be thrown.
DataEnqueuedInputStream::endOffering
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/DataEnqueuedInputStream.java
Apache-2.0
DataEnqueuedOutputStream(long timeoutMillis) { this.timeoutMillis = timeoutMillis; }
Create an OutputStream with timeout. @param timeoutMillis timeout in millis. If it's negative, the writes will never time out.
DataEnqueuedOutputStream::DataEnqueuedOutputStream
java
google/j2objc
jre_emul/Classes/com/google/j2objc/net/DataEnqueuedOutputStream.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/net/DataEnqueuedOutputStream.java
Apache-2.0
private NativeTimeZone(Object nativeTimeZone, String name, int rawOffset, int dstSavings, boolean useDaylightTime) { if (name.startsWith("GMT-")) { int offsetMillis = rawOffset; if (useDaylightTime) { offsetMillis += dstSavings; } setID(createGmtOffsetString(true, true, offsetMillis)); } else { setID(name); } this.nativeTimeZone = nativeTimeZone; this.rawOffset = rawOffset; this.dstSavings = dstSavings; this.useDaylightTime = useDaylightTime; }
Create an NSTimeZone-backed TimeZone instance. @param nativeTimeZone the NSTimeZone instance. @param name the native time zone's name. @param rawOffset the pre-calculated raw offset (in millis) from UTC. When TimeZone was designed, the assumption was that the rawOffset would be a constant at all times. We pre-compute this offset using the instant when the instance is created. @param useDaylightTime whether this time zone observes DST at the moment this instance is created.
NativeTimeZone::NativeTimeZone
java
google/j2objc
jre_emul/Classes/com/google/j2objc/util/NativeTimeZone.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/util/NativeTimeZone.java
Apache-2.0
public static boolean matchClassNamePrefix(String actual, String expected) { return actual.equals(expected) || actual.equals(getCamelCase(expected)); }
When reflection is stripped, the transpiled code uses NSStringFromClass to return the name of a class. For example, instead of getting something like java.lang.Throwable, we get JavaLangThrowable. <p>This method assumes that {@code actual} and {@code expected} contain a class name as prefix. Firts, it compares directly {@code actual} to {@code expected}; if it fails, then it compares {@actual} to the cammel case version of {@code expected}.
ReflectionUtil::matchClassNamePrefix
java
google/j2objc
jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java
Apache-2.0
public static long getSerialVersionUID(Class<? extends Serializable> clazz) { try { return clazz.getField("serialVersionUID").getLong(null); } catch (NoSuchFieldException | IllegalAccessException ex) { // ignored. return 0; } }
Transpiled code that directly acccess the serialVersionUID field when reflection is stripped won't compile because this field is also stripped. <p>Accessing it via reflection allows the non-stripped code to keep the same behavior and allows the stripped code to compile. Note that in the later case, a ReflectionStrippedError will be thrown, this is OK because serialization code is not supported when reflection is stripped.
ReflectionUtil::getSerialVersionUID
java
google/j2objc
jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/util/ReflectionUtil.java
Apache-2.0
private byte[] maybeDecodeBase64(byte[] byteArray) { try { String pem = new String(byteArray); // Remove required begin/end lines. pem = pem.substring(BEGIN_CERT_LINE_LENGTH, pem.length() - END_CERT_LINE_LENGTH); return Base64.getDecoder().decode(pem); } catch (Exception e) { // Not a valid PEM encoded certificate, return original array. return byteArray; } }
Test whether array is a Base64-encoded certificate. If so, return the decoded content instead of the specified array. @see CertificateFactorySpi#engineGenerateCertificate(InputStream)
IosCertificateFactory::maybeDecodeBase64
java
google/j2objc
jre_emul/Classes/com/google/j2objc/security/cert/IosCertificateFactory.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/security/cert/IosCertificateFactory.java
Apache-2.0
public static Object create(Delegate delegate, int bufferSize) { if (bufferSize < 1) { throw new IllegalArgumentException("Invalid buffer size: " + bufferSize); } if (delegate == null) { throw new IllegalArgumentException("Delegate must not be null"); } return nativeCreate(delegate, bufferSize); }
Creates a native NSInputStream that is piped to a NSOutpuStream, which in turn requests data from the supplied delegate asynchronously. <p>Please note that the returned NSInputStream is not yet open. This is to allow the stream to be used by other Foundation API (such as NSMutableURLRequest) and is consistent with other NSInputStream initializers. @param delegate the delegate. @param bufferSize the size of the internal buffer used to pipe the NSOutputStream to the NSInputStream. @return a native NSInputStream.
OutputStreamAdapter::create
java
google/j2objc
jre_emul/Classes/com/google/j2objc/io/AsyncPipedNSInputStreamAdapter.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/com/google/j2objc/io/AsyncPipedNSInputStreamAdapter.java
Apache-2.0
public static ClassLoader getClosestUserClassLoader() { return null; }
Stub implementation of getClosestUserClassLoader() Returns the first ClassLoader on the call stack that isn't the bootstrap class loader.
VMStack::getClosestUserClassLoader
java
google/j2objc
jre_emul/Classes/dalvik/system/VMStack.java
https://github.com/google/j2objc/blob/master/jre_emul/Classes/dalvik/system/VMStack.java
Apache-2.0
public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass, String getterName, String setterName, String indexedGetterName, String indexedSetterName) throws IntrospectionException { super(propertyName, beanClass, getterName, setterName); setIndexedByName(beanClass, indexedGetterName, indexedSetterName); }
Constructs a new instance of <code>IndexedPropertyDescriptor</code>. @param propertyName the specified indexed property's name. @param beanClass the bean class @param getterName the name of the array getter @param setterName the name of the array setter @param indexedGetterName the name of the indexed getter. @param indexedSetterName the name of the indexed setter. @throws IntrospectionException
IndexedPropertyDescriptor::IndexedPropertyDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public IndexedPropertyDescriptor(String propertyName, Method getter, Method setter, Method indexedGetter, Method indexedSetter) throws IntrospectionException { super(propertyName, getter, setter); if (indexedGetter != null) { internalSetIndexedReadMethod(indexedGetter); internalSetIndexedWriteMethod(indexedSetter, true); } else { internalSetIndexedWriteMethod(indexedSetter, true); internalSetIndexedReadMethod(indexedGetter); } if (!isCompatible()) { throw new IntrospectionException( "Property type is incompatible with the indexed property type"); } }
Constructs a new instance of <code>IndexedPropertyDescriptor</code>. @param propertyName the specified indexed property's name. @param getter the array getter @param setter the array setter @param indexedGetter the indexed getter @param indexedSetter the indexed setter @throws IntrospectionException
IndexedPropertyDescriptor::IndexedPropertyDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public IndexedPropertyDescriptor(String propertyName, Class<?> beanClass) throws IntrospectionException { super(propertyName, beanClass); setIndexedByName(beanClass, "get" //$NON-NLS-1$ .concat(initialUpperCase(propertyName)), "set" //$NON-NLS-1$ .concat(initialUpperCase(propertyName))); }
Constructs a new instance of <code>IndexedPropertyDescriptor</code>. @param propertyName the specified indexed property's name. @param beanClass the bean class. @throws IntrospectionException
IndexedPropertyDescriptor::IndexedPropertyDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public void setIndexedReadMethod(Method indexedGetter) throws IntrospectionException { this.internalSetIndexedReadMethod(indexedGetter); }
Sets the indexed getter as the specified method. @param indexedGetter the specified indexed getter. @throws IntrospectionException
IndexedPropertyDescriptor::setIndexedReadMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public void setIndexedWriteMethod(Method indexedSetter) throws IntrospectionException { this.internalSetIndexedWriteMethod(indexedSetter, false); }
Sets the indexed setter as the specified method. @param indexedSetter the specified indexed setter. @throws IntrospectionException
IndexedPropertyDescriptor::setIndexedWriteMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public Method getIndexedWriteMethod() { return indexedSetter; }
Obtains the indexed setter. @return the indexed setter.
IndexedPropertyDescriptor::getIndexedWriteMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public Method getIndexedReadMethod() { return indexedGetter; }
Obtains the indexed getter. @return the indexed getter.
IndexedPropertyDescriptor::getIndexedReadMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public Class<?> getIndexedPropertyType() { return indexedPropertyType; }
Obtains the Class object of the indexed property type. @return the Class object of the indexed property type.
IndexedPropertyDescriptor::getIndexedPropertyType
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/IndexedPropertyDescriptor.java
Apache-2.0
public static String decapitalize(String name) { if (name == null) return null; // The rule for decapitalize is that: // If the first letter of the string is Upper Case, make it lower case // UNLESS the second letter of the string is also Upper Case, in which case no // changes are made. if (name.length() == 0 || (name.length() > 1 && Character.isUpperCase(name.charAt(1)))) { return name; } char[] chars = name.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); }
Decapitalizes a given string according to the rule: <ul> <li>If the first or only character is Upper Case, it is made Lower Case <li>UNLESS the second character is also Upper Case, when the String is returned unchanged <eul> @param name - the String to decapitalize @return the decapitalized version of the String
Introspector::decapitalize
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static void flushCaches() { // Flush the cache by throwing away the cache HashMap and creating a // new empty one theCache.clear(); }
Flushes all <code>BeanInfo</code> caches.
Introspector::flushCaches
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static void flushFromCaches(Class<?> clazz) { if(clazz == null){ throw new NullPointerException(); } theCache.remove(clazz); }
Flushes the <code>BeanInfo</code> caches of the specified bean class @param clazz the specified bean class
Introspector::flushFromCaches
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException { StandardBeanInfo beanInfo = theCache.get(beanClass); if (beanInfo == null) { beanInfo = getBeanInfoImplAndInit(beanClass, null, USE_ALL_BEANINFO); theCache.put(beanClass, beanInfo); } return beanInfo; }
Gets the <code>BeanInfo</code> object which contains the information of the properties, events and methods of the specified bean class. <p> The <code>Introspector</code> will cache the <code>BeanInfo</code> object. Subsequent calls to this method will be answered with the cached data. </p> @param beanClass the specified bean class. @return the <code>BeanInfo</code> of the bean class. @throws IntrospectionException
Introspector::getBeanInfo
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static BeanInfo getBeanInfo(Class<?> beanClass, Class<?> stopClass) throws IntrospectionException { if(stopClass == null){ //try to use cache return getBeanInfo(beanClass); } return getBeanInfoImplAndInit(beanClass, stopClass, USE_ALL_BEANINFO); }
Gets the <code>BeanInfo</code> object which contains the information of the properties, events and methods of the specified bean class. It will not introspect the "stopclass" and its super class. <p> The <code>Introspector</code> will cache the <code>BeanInfo</code> object. Subsequent calls to this method will be answered with the cached data. </p> @param beanClass the specified beanClass. @param stopClass the sopt class which should be super class of the bean class. May be null. @return the <code>BeanInfo</code> of the bean class. @throws IntrospectionException
Introspector::getBeanInfo
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static BeanInfo getBeanInfo(Class<?> beanClass, int flags) throws IntrospectionException { if(flags == USE_ALL_BEANINFO){ //try to use cache return getBeanInfo(beanClass); } return getBeanInfoImplAndInit(beanClass, null, flags); }
Gets the <code>BeanInfo</code> object which contains the information of the properties, events and methods of the specified bean class. <ol> <li>If <code>flag==IGNORE_ALL_BEANINFO</code>, the <code>Introspector</code> will ignore all <code>BeanInfo</code> class.</li> <li>If <code>flag==IGNORE_IMMEDIATE_BEANINFO</code>, the <code>Introspector</code> will ignore the <code>BeanInfo</code> class of the current bean class.</li> <li>If <code>flag==USE_ALL_BEANINFO</code>, the <code>Introspector</code> will use all <code>BeanInfo</code> class which have been found.</li> </ol> <p> The <code>Introspector</code> will cache the <code>BeanInfo</code> object. Subsequent calls to this method will be answered with the cached data. </p> @param beanClass the specified bean class. @param flags the flag to control the usage of the explicit <code>BeanInfo</code> class. @return the <code>BeanInfo</code> of the bean class. @throws IntrospectionException
Introspector::getBeanInfo
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static String[] getBeanInfoSearchPath() { String[] path = new String[searchPath.length]; System.arraycopy(searchPath, 0, path, 0, searchPath.length); return path; }
Gets an array of search packages. @return an array of search packages.
Introspector::getBeanInfoSearchPath
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public static void setBeanInfoSearchPath(String[] path) { // if (System.getSecurityManager() != null) { // System.getSecurityManager().checkPropertiesAccess(); // } searchPath = path; }
Sets the search packages. @param path the new search packages to be set.
Introspector::setBeanInfoSearchPath
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
private static BeanInfo loadBeanInfo(String beanInfoClassName, Class<?> beanClass) throws Exception{ try { ClassLoader cl = beanClass.getClassLoader(); if(cl != null){ return (BeanInfo) Class.forName(beanInfoClassName, true, beanClass.getClassLoader()).newInstance(); } } catch (Exception e) { // fall through } try { return (BeanInfo) Class.forName(beanInfoClassName, true, ClassLoader.getSystemClassLoader()).newInstance(); } catch (Exception e) { // fall through } return (BeanInfo) Class.forName(beanInfoClassName, true, Thread.currentThread().getContextClassLoader()).newInstance(); }
Sets the search packages. @param path the new search packages to be set. public static void setBeanInfoSearchPath(String[] path) { // if (System.getSecurityManager() != null) { // System.getSecurityManager().checkPropertiesAccess(); // } searchPath = path; } private static StandardBeanInfo getBeanInfoImpl(Class<?> beanClass, Class<?> stopClass, int flags) throws IntrospectionException { BeanInfo explicitInfo = null; if (flags == USE_ALL_BEANINFO) { explicitInfo = getExplicitBeanInfo(beanClass); } StandardBeanInfo beanInfo = new StandardBeanInfo(beanClass, explicitInfo, stopClass); if (beanInfo.additionalBeanInfo != null) { for (int i = beanInfo.additionalBeanInfo.length-1; i >=0; i--) { BeanInfo info = beanInfo.additionalBeanInfo[i]; beanInfo.mergeBeanInfo(info, true); } } // recursive get beaninfo for super classes Class<?> beanSuperClass = beanClass.getSuperclass(); if (beanSuperClass != stopClass) { if (beanSuperClass == null) throw new IntrospectionException( "Stop class is not super class of bean class"); //$NON-NLS-1$ int superflags = flags == IGNORE_IMMEDIATE_BEANINFO ? USE_ALL_BEANINFO : flags; BeanInfo superBeanInfo = getBeanInfoImpl(beanSuperClass, stopClass, superflags); if (superBeanInfo != null) { beanInfo.mergeBeanInfo(superBeanInfo, false); } } return beanInfo; } private static BeanInfo getExplicitBeanInfo(Class<?> beanClass) { String beanInfoClassName = beanClass.getName() + "BeanInfo"; //$NON-NLS-1$ try { return loadBeanInfo(beanInfoClassName, beanClass); } catch (Exception e) { // fall through } int index = beanInfoClassName.lastIndexOf('.'); String beanInfoName = index >= 0 ? beanInfoClassName .substring(index + 1) : beanInfoClassName; BeanInfo theBeanInfo = null; BeanDescriptor beanDescriptor = null; for (int i = 0; i < searchPath.length; i++) { beanInfoClassName = searchPath[i] + "." + beanInfoName; //$NON-NLS-1$ try { theBeanInfo = loadBeanInfo(beanInfoClassName, beanClass); } catch (Exception e) { // ignore, try next one continue; } beanDescriptor = theBeanInfo.getBeanDescriptor(); if (beanDescriptor != null && beanClass == beanDescriptor.getBeanClass()) { return theBeanInfo; } } if (BeanInfo.class.isAssignableFrom(beanClass)) { try { return loadBeanInfo(beanClass.getName(), beanClass); } catch (Exception e) { // fall through } } return null; } /* Method which attempts to instantiate a BeanInfo object of the supplied classname @param theBeanInfoClassName - the Class Name of the class of which the BeanInfo is an instance @param classLoader @return A BeanInfo object which is an instance of the Class named theBeanInfoClassName null if the Class does not exist or if there are problems instantiating the instance
Introspector::loadBeanInfo
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/Introspector.java
Apache-2.0
public MethodDescriptor(Method method, ParameterDescriptor[] parameterDescriptors) { super(); if (method == null) { throw new NullPointerException(); } this.method = method; this.parameterDescriptors = parameterDescriptors; setName(method.getName()); }
<p> Constructs an instance with the given {@link Method} and {@link ParameterDescriptor}s. The {@link #getName()} is set as the name of the <code>method</code> passed. </p> @param method The Method to set. @param parameterDescriptors An array of parameter descriptors.
MethodDescriptor::MethodDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
Apache-2.0
public MethodDescriptor(Method method) { super(); if (method == null) { throw new NullPointerException(); } this.method = method; setName(method.getName()); }
<p> Constructs an instance with the given {@link Method}. The {@link #getName()} is set as the name of the <code>method</code> passed. </p> @param method The Method to set.
MethodDescriptor::MethodDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
Apache-2.0
public Method getMethod() { return method; }
<p> Gets the method. </p> @return A {@link Method} instance.
MethodDescriptor::getMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
Apache-2.0
public ParameterDescriptor[] getParameterDescriptors() { return parameterDescriptors; }
<p> Gets the parameter descriptors. </p> @return An array of {@link ParameterDescriptor} instance or <code>null</code>.
MethodDescriptor::getParameterDescriptors
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/MethodDescriptor.java
Apache-2.0
public FeatureDescriptor() { this.values = new HashMap<String, Object>(); }
<p> Constructs an instance. </p>
FeatureDescriptor::FeatureDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setValue(String attributeName, Object value) { if (attributeName == null || value == null) { throw new NullPointerException(); } values.put(attributeName, value); }
<p> Sets the value for the named attribute. </p> @param attributeName The name of the attribute to set a value with. @param value The value to set.
FeatureDescriptor::setValue
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public Object getValue(String attributeName) { if (attributeName != null) { return values.get(attributeName); } return null; }
<p> Gets the value associated with the named attribute. </p> @param attributeName The name of the attribute to get a value for. @return The attribute's value.
FeatureDescriptor::getValue
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public Enumeration<String> attributeNames() { // Create a new list, so that the references are copied return Collections.enumeration(new LinkedList<String>(values.keySet())); }
<p> Enumerates the attribute names. </p> @return An instance of {@link Enumeration}.
FeatureDescriptor::attributeNames
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setShortDescription(String text) { this.shortDescription = text; }
<p> Sets the short description. </p> @param text The description to set.
FeatureDescriptor::setShortDescription
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setName(String name) { this.name = name; }
<p> Sets the name. </p> @param name The name to set.
FeatureDescriptor::setName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setDisplayName(String displayName) { this.displayName = displayName; }
<p> Sets the display name. </p> @param displayName The display name to set.
FeatureDescriptor::setDisplayName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public String getShortDescription() { return shortDescription == null ? getDisplayName() : shortDescription; }
<p> Gets the short description or {@link #getDisplayName()} if not set. </p> @return The description.
FeatureDescriptor::getShortDescription
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public String getName() { return name; }
<p> Gets the name. </p> @return The name.
FeatureDescriptor::getName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public String getDisplayName() { return displayName == null ? getName() : displayName; }
<p> Gets the display name or {@link #getName()} if not set. </p> @return The display name.
FeatureDescriptor::getDisplayName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setPreferred(boolean preferred) { this.preferred = preferred; }
<p> Sets the preferred indicator. </p> @param preferred <code>true</code> if preferred, <code>false</code> otherwise.
FeatureDescriptor::setPreferred
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setHidden(boolean hidden) { this.hidden = hidden; }
<p> Sets the hidden indicator. </p> @param hidden <code>true</code> if hidden, <code>false</code> otherwise.
FeatureDescriptor::setHidden
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public void setExpert(boolean expert) { this.expert = expert; }
<p> Sets the expert indicator. </p> @param expert <code>true</code> if expert, <code>false</code> otherwise.
FeatureDescriptor::setExpert
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public boolean isPreferred() { return preferred; }
<p> Indicates if this feature is preferred. </p> @return <code>true</code> if preferred, <code>false</code> otherwise.
FeatureDescriptor::isPreferred
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public boolean isHidden() { return hidden; }
<p> Indicates if this feature is hidden. </p> @return <code>true</code> if hidden, <code>false</code> otherwise.
FeatureDescriptor::isHidden
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public boolean isExpert() { return expert; }
<p> Indicates if this feature is an expert feature. </p> @return <code>true</code> if hidden, <code>false</code> otherwise.
FeatureDescriptor::isExpert
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/FeatureDescriptor.java
Apache-2.0
public PropertyVetoException(String message, PropertyChangeEvent event) { super(message); this.evt = event; }
<p> Constructs an instance with a message and the change event. </p> @param message A description of the veto. @param event The event that was vetoed.
PropertyVetoException::PropertyVetoException
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/PropertyVetoException.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/PropertyVetoException.java
Apache-2.0
public PropertyChangeEvent getPropertyChangeEvent() { return evt; }
<p> Gets the property change event. </p> @return An instance of {@link PropertyChangeEvent}
PropertyVetoException::getPropertyChangeEvent
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/PropertyVetoException.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/PropertyVetoException.java
Apache-2.0
public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) { if (beanClass == null) { throw new NullPointerException(); } setName(getShortClassName(beanClass)); this.beanClass = beanClass; this.customizerClass = customizerClass; }
<p> Constructs an instance with the bean's {@link Class} and a customizer {@link Class}. The descriptor's {@link #getName()} is set as the unqualified name of the <code>beanClass</code>. </p> @param beanClass The bean's Class. @param customizerClass The bean's customizer Class.
BeanDescriptor::BeanDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
Apache-2.0
public BeanDescriptor(Class<?> beanClass) { this(beanClass, null); }
<p> Constructs an instance with the bean's {@link Class}. The descriptor's {@link #getName()} is set as the unqualified name of the <code>beanClass</code>. </p> @param beanClass The bean's Class.
BeanDescriptor::BeanDescriptor
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
Apache-2.0
public Class<?> getCustomizerClass() { return customizerClass; }
<p> Gets the bean's customizer {@link Class}/ </p> @return A {@link Class} instance or <code>null</code>.
BeanDescriptor::getCustomizerClass
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
Apache-2.0
public Class<?> getBeanClass() { return beanClass; }
<p> Gets the bean's {@link Class}. </p> @return A {@link Class} instance.
BeanDescriptor::getBeanClass
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
Apache-2.0
private String getShortClassName(Class<?> leguminaClass) { if(leguminaClass == null) { return null; } String beanClassName = leguminaClass.getName(); int lastIndex = beanClassName.lastIndexOf("."); //$NON-NLS-1$ return (lastIndex == -1) ? beanClassName : beanClassName.substring(lastIndex + 1); }
<p> Utility method for getting the unqualified name of a {@link Class}. </p> @param leguminaClass The Class to get the name from. @return A String instance or <code>null</code>.
BeanDescriptor::getShortClassName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/BeanDescriptor.java
Apache-2.0
private static void checkEventType(String eventSetName, Method listenerMethod) throws IntrospectionException { Class<?>[] params = listenerMethod.getParameterTypes(); String firstParamTypeName = null; String eventTypeName = prepareEventTypeName(eventSetName); if (params.length > 0) { firstParamTypeName = extractShortClassName(params[0] .getName()); } if (firstParamTypeName == null || !firstParamTypeName.equals(eventTypeName)) { throw new IntrospectionException("Listener method " + listenerMethod.getName() + " should have parameter of type " + eventTypeName); } }
Checks that given listener method has an argument of the valid type. @param eventSetName event set name @param listenerMethod listener method @throws IntrospectionException if check fails
EventSetDescriptor::checkEventType
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
Apache-2.0
private static String extractShortClassName(String fullClassName) { int k = fullClassName.lastIndexOf('$'); k = (k == -1 ? fullClassName.lastIndexOf('.') : k); return fullClassName.substring(k + 1); }
@param fullClassName full name of the class @return name with package and encapsulating class info omitted
EventSetDescriptor::extractShortClassName
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
Apache-2.0
private Method findAddRemoveListenerMethod(Class<?> sourceClass, String methodName) throws IntrospectionException { try { return sourceClass.getMethod(methodName, listenerType); } catch (NoSuchMethodException e) { return findAddRemoveListnerMethodWithLessCheck(sourceClass, methodName); } catch (Exception e) { throw new IntrospectionException("No valid method " + methodName + " for " + listenerType.getName() + " found."); } }
Searches for {add|remove}Listener methods in the event source. Parameter check is also performed. @param sourceClass event source class @param methodName method name to search @return found method @throws IntrospectionException if no valid method found
EventSetDescriptor::findAddRemoveListenerMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
Apache-2.0
private Method findGetListenerMethod(Class<?> sourceClass, String methodName) { try { return sourceClass.getMethod(methodName); } catch (Exception e) { // RI keeps silence here and just returns null return null; } }
@param sourceClass class of event source @param methodName name of the custom getListeners() method @return found Method object for custom getListener or null if nothing is found
EventSetDescriptor::findGetListenerMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/main/java/java/beans/EventSetDescriptor.java
Apache-2.0
public void testMethodDescriptorMethod() throws SecurityException, NoSuchMethodException { String beanName = "MethodDescriptorTest.bean"; MockJavaBean bean = new MockJavaBean(beanName); Method method = bean.getClass() .getMethod("getBeanName", (Class[]) null); MethodDescriptor md = new MethodDescriptor(method); assertSame(method, md.getMethod()); assertNull(md.getParameterDescriptors()); assertEquals(method.getName(), md.getDisplayName()); assertEquals(method.getName(), md.getName()); assertEquals(method.getName(), md.getShortDescription()); assertNotNull(md.attributeNames()); assertFalse(md.isExpert()); assertFalse(md.isHidden()); assertFalse(md.isPreferred()); }
Unit test for MethodDescriptor public class MethodDescriptorTest extends TestCase { /* @see TestCase#setUp() @Override protected void setUp() throws Exception { super.setUp(); } /* @see TestCase#tearDown() @Override protected void tearDown() throws Exception { super.tearDown(); } /* Class under test for void MethodDescriptor(Method)
MethodDescriptorTest::testMethodDescriptorMethod
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
Apache-2.0
public void testMethodDescriptorMethodParameterDescriptorArray() throws SecurityException, NoSuchMethodException { String beanName = "MethodDescriptorTest.bean"; MockJavaBean bean = new MockJavaBean(beanName); Method method = bean.getClass().getMethod("setPropertyOne", new Class[] { String.class }); ParameterDescriptor[] pds = new ParameterDescriptor[1]; pds[0] = new ParameterDescriptor(); pds[0].setValue(method.getName(), method.getReturnType()); MethodDescriptor md = new MethodDescriptor(method, pds); assertSame(method, md.getMethod()); assertSame(pds, md.getParameterDescriptors()); assertEquals(pds[0].getValue(method.getName()), md .getParameterDescriptors()[0].getValue(method.getName())); assertEquals(method.getName(), md.getDisplayName()); assertEquals(method.getName(), md.getName()); assertEquals(method.getName(), md.getShortDescription()); assertNotNull(md.attributeNames()); assertFalse(md.isExpert()); assertFalse(md.isHidden()); assertFalse(md.isPreferred()); }
Unit test for MethodDescriptor public class MethodDescriptorTest extends TestCase { /* @see TestCase#setUp() @Override protected void setUp() throws Exception { super.setUp(); } /* @see TestCase#tearDown() @Override protected void tearDown() throws Exception { super.tearDown(); } /* Class under test for void MethodDescriptor(Method) public void testMethodDescriptorMethod() throws SecurityException, NoSuchMethodException { String beanName = "MethodDescriptorTest.bean"; MockJavaBean bean = new MockJavaBean(beanName); Method method = bean.getClass() .getMethod("getBeanName", (Class[]) null); MethodDescriptor md = new MethodDescriptor(method); assertSame(method, md.getMethod()); assertNull(md.getParameterDescriptors()); assertEquals(method.getName(), md.getDisplayName()); assertEquals(method.getName(), md.getName()); assertEquals(method.getName(), md.getShortDescription()); assertNotNull(md.attributeNames()); assertFalse(md.isExpert()); assertFalse(md.isHidden()); assertFalse(md.isPreferred()); } public void testMethodDescriptorMethod_Null() { Method method = null; try { new MethodDescriptor(method); fail("Should throw NullPointerException."); } catch (NullPointerException e) { } } /* Class under test for void MethodDescriptor(Method, ParameterDescriptor[])
MethodDescriptorTest::testMethodDescriptorMethodParameterDescriptorArray
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/MethodDescriptorTest.java
Apache-2.0
public void testPropertyChange_PropertyChangeEvent() { PropertyChangeListenerProxy proxy = new PropertyChangeListenerProxy( "harmony", null); try { proxy.propertyChange(null); fail("NullPointerException expected"); } catch (NullPointerException e) { } }
Regression for HARMONY-407
PropertyChangeListenerProxyTest::testPropertyChange_PropertyChangeEvent
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyChangeListenerProxyTest.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyChangeListenerProxyTest.java
Apache-2.0
public void testBeanDescriptorClass() { String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new MockJavaBean(beanName); Class<? extends MockJavaBean> beanClass = bean.getClass(); BeanDescriptor bd = new BeanDescriptor(beanClass); assertSame(beanClass, bd.getBeanClass()); String displayName = beanClass.getName().substring( beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName, bd.getDisplayName()); assertEquals(displayName, bd.getName()); assertEquals(displayName, bd.getShortDescription()); assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert()); assertFalse(bd.isHidden()); assertFalse(bd.isPreferred()); }
Unit test for BeanDescriptor. public class BeanDescriptorTest extends TestCase { /* @see TestCase#setUp() @Override protected void setUp() throws Exception { super.setUp(); } /* @see TestCase#tearDown() @Override protected void tearDown() throws Exception { super.tearDown(); } /* Class under test for void BeanDescriptor(Class)
BeanDescriptorTest::testBeanDescriptorClass
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
Apache-2.0
public void testBeanDescriptorClassClass() { /* * String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new * MockJavaBean(beanName); Class beanClass = bean.getClass(); Customizer * customizer = new MyCustomizer(); Class cusClass = * customizer.getClass(); BeanDescriptor bd = new * BeanDescriptor(beanClass, cusClass); * * assertSame(beanClass, bd.getBeanClass()); assertSame(cusClass, * bd.getCustomizerClass()); * * String displayName = beanClass.getName().substring( * beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName, * bd.getDisplayName()); assertEquals(displayName, bd.getName()); * assertEquals(displayName, bd.getShortDescription()); * * assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert()); * assertFalse(bd.isHidden()); assertFalse(bd.isPreferred()); */ }
Unit test for BeanDescriptor. public class BeanDescriptorTest extends TestCase { /* @see TestCase#setUp() @Override protected void setUp() throws Exception { super.setUp(); } /* @see TestCase#tearDown() @Override protected void tearDown() throws Exception { super.tearDown(); } /* Class under test for void BeanDescriptor(Class) public void testBeanDescriptorClass() { String beanName = "BeanDescriptorTest.bean"; MockJavaBean bean = new MockJavaBean(beanName); Class<? extends MockJavaBean> beanClass = bean.getClass(); BeanDescriptor bd = new BeanDescriptor(beanClass); assertSame(beanClass, bd.getBeanClass()); String displayName = beanClass.getName().substring( beanClass.getName().lastIndexOf('.') + 1); assertEquals(displayName, bd.getDisplayName()); assertEquals(displayName, bd.getName()); assertEquals(displayName, bd.getShortDescription()); assertNotNull(bd.attributeNames()); assertFalse(bd.isExpert()); assertFalse(bd.isHidden()); assertFalse(bd.isPreferred()); } public void testBeanDescriptorClass_Null() { try { new BeanDescriptor(null); fail("Should throw NullPointerException."); } catch (NullPointerException e) { } } /* Class under test for void BeanDescriptor(Class, Class)
BeanDescriptorTest::testBeanDescriptorClassClass
java
google/j2objc
jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
https://github.com/google/j2objc/blob/master/jre_emul/apache_harmony/classlib/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/BeanDescriptorTest.java
Apache-2.0