Author: rotty3000 Date: Wed Dec 19 22:29:43 2018 New Revision: 1849342 URL: http://svn.apache.org/viewvc?rev=1849342&view=rev Log: FELIX-5999 cleanup compiler warnings
Signed-off-by: Raymond Auge <[email protected]> Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Activator.java felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Files.java felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Activator.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Converters.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Expander.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Main.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Procedural.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/SingleServiceTracker.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/AbstractParserTest.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellCommand.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellFactoryImpl.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/Ssh.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/BootException.java felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/TelnetIO.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandNotFoundException.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProxy.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Converters.java Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Activator.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Activator.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Activator.java (original) +++ felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Activator.java Wed Dec 19 22:29:43 2018 @@ -21,7 +21,6 @@ package org.apache.felix.gogo.command; import java.util.Hashtable; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.util.tracker.ServiceTracker; public class Activator implements BundleActivator { Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Files.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Files.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Files.java (original) +++ felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Files.java Wed Dec 19 22:29:43 2018 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -31,6 +31,7 @@ import static org.apache.felix.gogo.comm public class Files { + @SuppressWarnings("unused") private final BundleContext m_bc; public Files(BundleContext bc) Modified: felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java (original) +++ felix/trunk/gogo/command/src/main/java/org/apache/felix/gogo/command/Inspect.java Wed Dec 19 22:29:43 2018 @@ -217,13 +217,13 @@ public class Inspect try { - ServiceReference[] refs = b.getRegisteredServices(); + ServiceReference<?>[] refs = b.getRegisteredServices(); if ((refs != null) && (refs.length > 0)) { matches = true; // Print properties for each service. - for (ServiceReference ref : refs) + for (ServiceReference<?> ref : refs) { // Print object class with "namespace". System.out.println( @@ -392,13 +392,13 @@ public class Inspect try { - ServiceReference[] refs = b.getServicesInUse(); + ServiceReference<?>[] refs = b.getServicesInUse(); if ((refs != null) && (refs.length > 0)) { matches = true; // Print properties for each service. - for (ServiceReference ref : refs) + for (ServiceReference<?> ref : refs) { // Print object class with "namespace". System.out.println( @@ -437,9 +437,4 @@ public class Inspect { return (CAPABILITY.startsWith(direction) || REQUIREMENT.startsWith(direction)); } - - private static boolean isFragment(Bundle bundle) - { - return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null; - } } \ No newline at end of file Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Activator.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Activator.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Activator.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Activator.java Wed Dec 19 22:29:43 2018 @@ -60,7 +60,7 @@ public class Activator implements Bundle public void stop(BundleContext context) { Iterator<ServiceRegistration<?>> iterator = regs.iterator(); while (iterator.hasNext()) { - ServiceRegistration reg = iterator.next(); + ServiceRegistration<?> reg = iterator.next(); reg.unregister(); iterator.remove(); } Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Builtin.java Wed Dec 19 22:29:43 2018 @@ -49,7 +49,6 @@ import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.felix.gogo.runtime.Reflective; import org.apache.felix.service.command.Job; import org.apache.felix.service.command.Process; import org.apache.felix.gogo.runtime.CommandSessionImpl; Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Converters.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Converters.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Converters.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Converters.java Wed Dec 19 22:29:43 2018 @@ -27,7 +27,6 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; import org.osgi.framework.startlevel.BundleStartLevel; -import org.osgi.service.startlevel.StartLevel; public class Converters extends BaseConverters { private final BundleContext context; @@ -44,20 +43,21 @@ public class Converters extends BaseConv getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); } - private CharSequence print(ServiceReference ref) { + private CharSequence print(ServiceReference<?> ref) { StringBuilder sb = new StringBuilder(); - Formatter f = new Formatter(sb); + try (Formatter f = new Formatter(sb);) + { + String spid = ""; + Object pid = ref.getProperty("service.pid"); + if (pid != null) { + spid = pid.toString(); + } - String spid = ""; - Object pid = ref.getProperty("service.pid"); - if (pid != null) { - spid = pid.toString(); + f.format("%06d %3s %-40s %s", ref.getProperty("service.id"), + ref.getBundle().getBundleId(), + getShortNames((String[]) ref.getProperty("objectclass")), spid); + return sb; } - - f.format("%06d %3s %-40s %s", ref.getProperty("service.id"), - ref.getBundle().getBundleId(), - getShortNames((String[]) ref.getProperty("objectclass")), spid); - return sb; } private CharSequence getShortNames(String[] list) { @@ -122,14 +122,14 @@ public class Converters extends BaseConv private Object convertServiceReference(Object in) throws InvalidSyntaxException { String s = in.toString(); if (s.startsWith("(") && s.endsWith(")")) { - ServiceReference refs[] = context.getServiceReferences((String) null, String.format( + ServiceReference<?> refs[] = context.getServiceReferences((String) null, String.format( "(|(service.id=%s)(service.pid=%s))", in, in)); if (refs != null && refs.length > 0) { return refs[0]; } } - ServiceReference refs[] = context.getServiceReferences((String) null, String.format( + ServiceReference<?> refs[] = context.getServiceReferences((String) null, String.format( "(|(service.id=%s)(service.pid=%s))", in, in)); if (refs != null && refs.length > 0) { return refs[0]; @@ -166,13 +166,13 @@ public class Converters extends BaseConv return print((Bundle) target); } if (level == LINE && target instanceof ServiceReference) { - return print((ServiceReference) target); + return print((ServiceReference<?>) target); } if (level == PART && target instanceof Bundle) { return ((Bundle) target).getSymbolicName(); } if (level == PART && target instanceof ServiceReference) { - return getShortNames((String[]) ((ServiceReference) target).getProperty("objectclass")); + return getShortNames((String[]) ((ServiceReference<?>) target).getProperty("objectclass")); } return super.format(target, level, converter); } Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Expander.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Expander.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Expander.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Expander.java Wed Dec 19 22:29:43 2018 @@ -35,6 +35,7 @@ public class Expander extends DefaultExp } @Override + @SuppressWarnings("unchecked") public String expandVar(String word) { try { Object o = org.apache.felix.gogo.runtime.Expander.expand( Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Highlighter.java Wed Dec 19 22:29:43 2018 @@ -142,7 +142,7 @@ public class Highlighter extends Default type = Type.Number; } else if (token.charAt(0) == '$') { type = Type.Variable; - } else if (((Set) session.get(CommandSessionImpl.CONSTANTS)).contains(token.toString()) + } else if (((Set<?>) session.get(CommandSessionImpl.CONSTANTS)).contains(token.toString()) || Token.eq(token, "null") || Token.eq(token, "false") || Token.eq(token, "true")) { type = Type.Constant; } else { Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Main.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Main.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Main.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Main.java Wed Dec 19 22:29:43 2018 @@ -23,7 +23,6 @@ import java.io.FilterOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.PrintStream; import org.apache.felix.gogo.jline.Shell.Context; import org.apache.felix.gogo.runtime.CommandProcessorImpl; Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Posix.java Wed Dec 19 22:29:43 2018 @@ -104,7 +104,8 @@ public class Posix { // TTop function is new in JLine 3.2 String[] func; try { - Class cl = TTop.class; + @SuppressWarnings("unused") + Class<?> cl = TTop.class; func = new String[] { "cat", "echo", "grep", "sort", "sleep", "cd", "pwd", "ls", "less", "watch", "nano", "tmux", @@ -154,6 +155,7 @@ public class Posix { } } + @SuppressWarnings("serial") protected static class HelpException extends Exception { public HelpException(String message) { super(message); @@ -770,6 +772,7 @@ public class Posix { "Usage: clear [OPTIONS]", " -? --help Show help", }; + @SuppressWarnings("unused") Options opt = parseOptions(session, usage, argv); if (process.isTty(1)) { Shell.getTerminal(session).puts(Capability.clear_screen); Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Procedural.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Procedural.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Procedural.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Procedural.java Wed Dec 19 22:29:43 2018 @@ -54,27 +54,32 @@ public class Procedural { return null; } + @SuppressWarnings("serial") protected static class OptionException extends Exception { public OptionException(String message, Throwable cause) { super(message, cause); } } + @SuppressWarnings("serial") protected static class HelpException extends Exception { public HelpException(String message) { super(message); } } + @SuppressWarnings("serial") protected static class ThrownException extends Exception { public ThrownException(Throwable cause) { super(cause); } } + @SuppressWarnings("serial") protected static class BreakException extends Exception { } + @SuppressWarnings("serial") protected static class ContinueException extends Exception { } Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/Shell.java Wed Dec 19 22:29:43 2018 @@ -20,12 +20,10 @@ package org.apache.felix.gogo.jline; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintStream; import java.io.PrintWriter; -import java.io.Reader; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -144,7 +142,7 @@ public class Shell { @SuppressWarnings("unchecked") public static Map<String, List<CompletionData>> getCompletions(CommandSession session) { - return (Map) session.get(VAR_COMPLETIONS); + return (Map<String, List<CompletionData>>) session.get(VAR_COMPLETIONS); } @SuppressWarnings("unchecked") @@ -361,7 +359,7 @@ public class Shell { .build(); reader.setOpt(LineReader.Option.AUTO_FRESH_LINE); session.put(Shell.VAR_READER, reader); - session.put(Shell.VAR_COMPLETIONS, new HashMap()); + session.put(Shell.VAR_COMPLETIONS, new HashMap<>()); } else { reader = null; } Modified: felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/SingleServiceTracker.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/SingleServiceTracker.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/SingleServiceTracker.java (original) +++ felix/trunk/gogo/jline/src/main/java/org/apache/felix/gogo/jline/SingleServiceTracker.java Wed Dec 19 22:29:43 2018 @@ -46,7 +46,7 @@ public final class SingleServiceTracker< private final BundleContext ctx; private final String className; private final AtomicReference<T> service = new AtomicReference<>(); - private final AtomicReference<ServiceReference> ref = new AtomicReference<>(); + private final AtomicReference<ServiceReference<?>> ref = new AtomicReference<>(); private final AtomicBoolean open = new AtomicBoolean(false); private final SingleServiceListener serviceListener; private final String filterString; @@ -77,7 +77,7 @@ public final class SingleServiceTracker< return service.get(); } - public ServiceReference getServiceReference() { + public ServiceReference<?> getServiceReference() { return ref.get(); } @@ -97,7 +97,7 @@ public final class SingleServiceTracker< public void serviceChanged(ServiceEvent event) { if (open.get()) { if (event.getType() == ServiceEvent.UNREGISTERING) { - ServiceReference deadRef = event.getServiceReference(); + ServiceReference<?> deadRef = event.getServiceReference(); if (deadRef.equals(ref.get())) { findMatchingReference(deadRef); } @@ -107,10 +107,10 @@ public final class SingleServiceTracker< } } - private void findMatchingReference(ServiceReference original) { + private void findMatchingReference(ServiceReference<?> original) { try { boolean clear = true; - ServiceReference[] refs = ctx.getServiceReferences(className, filterString); + ServiceReference<?>[] refs = ctx.getServiceReferences(className, filterString); if (refs != null && refs.length > 0) { if (refs.length > 1) { Arrays.sort(refs); @@ -137,7 +137,7 @@ public final class SingleServiceTracker< } } - private boolean update(ServiceReference deadRef, ServiceReference newRef, T service) { + private boolean update(ServiceReference<?> deadRef, ServiceReference<?> newRef, T service) { boolean result = false; int foundLostReplaced = -1; @@ -177,7 +177,7 @@ public final class SingleServiceTracker< if (open.compareAndSet(true, false)) { ctx.removeServiceListener(this); - ServiceReference deadRef; + ServiceReference<?> deadRef; synchronized (this) { deadRef = ref.getAndSet(null); service.set(null); Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/AbstractParserTest.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/AbstractParserTest.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/AbstractParserTest.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/AbstractParserTest.java Wed Dec 19 22:29:43 2018 @@ -19,7 +19,6 @@ package org.apache.felix.gogo.jline; import java.io.FilterInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellCommand.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellCommand.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellCommand.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellCommand.java Wed Dec 19 22:29:43 2018 @@ -21,7 +21,6 @@ package org.apache.felix.gogo.jline.ssh; import java.io.CharArrayWriter; import java.io.File; import java.io.FileInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; @@ -51,6 +50,7 @@ public class ShellCommand implements Com private OutputStream out; private OutputStream err; private ExitCallback callback; + @SuppressWarnings("unused") private ServerSession session; private CommandProcessor processor; private Environment env; Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellFactoryImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellFactoryImpl.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellFactoryImpl.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/ShellFactoryImpl.java Wed Dec 19 22:29:43 2018 @@ -90,6 +90,7 @@ public class ShellFactoryImpl implements private ExitCallback callback; + @SuppressWarnings("unused") private ServerSession session; private boolean closed; @@ -227,6 +228,7 @@ public class ShellFactoryImpl implements case OPOST: attr.setOutputFlag(OutputFlag.OPOST, e.getValue() != 0); break; + default: } } terminal.setAttributes(attr); Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/Ssh.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/Ssh.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/Ssh.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/ssh/Ssh.java Wed Dec 19 22:29:43 2018 @@ -24,8 +24,6 @@ import java.util.List; import org.apache.felix.service.command.CommandProcessor; import org.apache.felix.service.command.CommandSession; -import org.apache.sshd.common.NamedFactory; -import org.apache.sshd.server.Command; import org.apache.sshd.server.ServerBuilder; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; @@ -41,6 +39,7 @@ public class Ssh { private final CommandProcessor processor; private SshServer server; + @SuppressWarnings("unused") private Object context; private int port; private String ip; Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/BootException.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/BootException.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/BootException.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/BootException.java Wed Dec 19 22:29:43 2018 @@ -59,6 +59,7 @@ package org.apache.felix.gogo.jline.teln * @author Dieter Wimberger * @version 2.0 (16/07/2006) */ +@SuppressWarnings("serial") public class BootException extends Exception { /** Modified: felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/TelnetIO.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/TelnetIO.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/TelnetIO.java (original) +++ felix/trunk/gogo/jline/src/test/java/org/apache/felix/gogo/jline/telnet/TelnetIO.java Wed Dec 19 22:29:43 2018 @@ -312,6 +312,7 @@ public class TelnetIO { //Members private InetAddress localAddress; //address of the host the telnetd is running on private boolean noIac = false; //describes if IAC was found and if its just processed + @SuppressWarnings("unused") private boolean initializing; private boolean crFlag; /** @@ -693,6 +694,7 @@ public class TelnetIO { private boolean WAIT_LM_MODE_ACK = false; private boolean WAIT_LM_DO_REPLY_FORWARDMASK = false; private boolean WAIT_DO_REPLY_NEWENV = false; + @SuppressWarnings("unused") private boolean WAIT_NE_SEND_REPLY = false; /** Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/BaseTokenizer.java Wed Dec 19 22:29:43 2018 @@ -164,7 +164,6 @@ public class BaseTokenizer skipSpace(false); } - @SuppressWarnings("StatementWithEmptyBody") protected void skipSpace(boolean skipNewLines) { while (true) @@ -202,6 +201,7 @@ public class BaseTokenizer { while ((getch() != EOT) && ('\n' != ch)) { + //loop } continue; } @@ -213,6 +213,7 @@ public class BaseTokenizer while ((getch() != EOT) && !(('*' == ch) && (peek() == '/'))) { + //loop } if (EOT == ch) Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandNotFoundException.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandNotFoundException.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandNotFoundException.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandNotFoundException.java Wed Dec 19 22:29:43 2018 @@ -20,6 +20,7 @@ package org.apache.felix.gogo.runtime; /** * Thrown if an unknown command is entered into a shell or passed on the command line */ +@SuppressWarnings("serial") public class CommandNotFoundException extends IllegalArgumentException { private final String command; Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProcessorImpl.java Wed Dec 19 22:29:43 2018 @@ -107,7 +107,7 @@ public class CommandProcessorImpl implem session.close(); } // Just in case... - sessions.clear(); + sessions.clear(); } } Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProxy.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProxy.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProxy.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandProxy.java Wed Dec 19 22:29:43 2018 @@ -28,11 +28,11 @@ import org.osgi.framework.ServiceReferen public class CommandProxy implements Function { private BundleContext context; - private ServiceReference reference; + private ServiceReference<?> reference; private String function; private Object target; - public CommandProxy(BundleContext context, ServiceReference reference, String function) + public CommandProxy(BundleContext context, ServiceReference<?> reference, String function) { this.context = context; this.reference = reference; Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java Wed Dec 19 22:29:43 2018 @@ -378,10 +378,10 @@ public class CommandSessionImpl implemen if (target instanceof Dictionary) { Map<Object, Object> result = new HashMap<>(); - for (Enumeration e = ((Dictionary) target).keys(); e.hasMoreElements();) + for (Enumeration<Object> e = ((Dictionary<Object, Object>) target).keys(); e.hasMoreElements();) { Object key = e.nextElement(); - result.put(key, ((Dictionary) target).get(key)); + result.put(key, ((Dictionary<Object, Object>) target).get(key)); } target = result; } @@ -441,34 +441,36 @@ public class CommandSessionImpl implemen CharSequence inspect(Object b) { boolean found = false; - Formatter f = new Formatter(); - Method methods[] = b.getClass().getMethods(); - for (Method m : methods) + try (Formatter f = new Formatter();) { - try + Method methods[] = b.getClass().getMethods(); + for (Method m : methods) { - String name = m.getName(); - if (m.getName().startsWith("get") && !m.getName().equals("getClass") && m.getParameterTypes().length == 0 && Modifier.isPublic(m.getModifiers())) + try { - found = true; - name = name.substring(3); - m.setAccessible(true); - Object value = m.invoke(b, (Object[]) null); - f.format(COLUMN, name, format(value, Converter.LINE, this)); + String name = m.getName(); + if (m.getName().startsWith("get") && !m.getName().equals("getClass") && m.getParameterTypes().length == 0 && Modifier.isPublic(m.getModifiers())) + { + found = true; + name = name.substring(3); + m.setAccessible(true); + Object value = m.invoke(b, (Object[]) null); + f.format(COLUMN, name, format(value, Converter.LINE, this)); + } + } + catch (Exception e) + { + // Ignore } } - catch (Exception e) + if (found) { - // Ignore + return (StringBuilder) f.out(); + } + else + { + return b.toString(); } - } - if (found) - { - return (StringBuilder) f.out(); - } - else - { - return b.toString(); } } @@ -683,7 +685,7 @@ public class CommandSessionImpl implemen @Override public void interrupt() { - Future future; + Future<?> future; List<Job> children; synchronized (this) { @@ -791,6 +793,8 @@ public class CommandSessionImpl implemen case Foreground: foreground(); break; + case Created: + case Done: } future = executor.submit(this); while (this.status == Status.Foreground) Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expander.java Wed Dec 19 22:29:43 2018 @@ -42,7 +42,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -@SuppressWarnings("fallthrough") public class Expander extends BaseTokenizer { @@ -772,7 +771,7 @@ public class Expander extends BaseTokeni { boolean first = true; buf.append("\""); - for (Object o : ((Collection) expand)) + for (Object o : ((Collection<?>) expand)) { if (!first) { @@ -1372,7 +1371,7 @@ public class Expander extends BaseTokeni if (val1 instanceof Collection) { List<String> l = new ArrayList<>(); - for (Object o : ((Collection) val1)) + for (Object o : ((Collection<?>) val1)) { if (flagG) { @@ -1466,19 +1465,19 @@ public class Expander extends BaseTokeni } else { - val = ((Map) val).get(sLeft); + val = ((Map<?,?>) val).get(sLeft); } } else if (val instanceof List) { if (sLeft.equals("@") || sLeft.equals("*")) { - val = new ArgList((List) val); + val = new ArgList((List<?>) val); } else { int iLeft = Integer.parseInt(sLeft); - List list = (List) val; + List<?> list = (List<?>) val; val = list.get(nLeft ? list.size() - 1 - iLeft : iLeft); } } @@ -1537,7 +1536,7 @@ public class Expander extends BaseTokeni int iRight = Integer.parseInt(right.toString()); if (val instanceof List) { - List list = (List) val; + List<?> list = (List<?>) val; val = list.subList(nLeft ? list.size() - iLeft : iLeft, nRight ? list.size() - iRight : iRight); } @@ -1593,11 +1592,11 @@ public class Expander extends BaseTokeni { if (val instanceof Collection) { - val = ((Collection) val).size(); + val = ((Collection<?>) val).size(); } else if (val instanceof Map) { - val = ((Map) val).size(); + val = ((Map<?,?>) val).size(); } else if (val != null) { @@ -1689,7 +1688,7 @@ public class Expander extends BaseTokeni val = toCollection.apply(val); if (val instanceof Collection) { - List<Object> list; + List<String> list; if (flagn) { final boolean _flagi = flagi; @@ -1698,7 +1697,7 @@ public class Expander extends BaseTokeni l.add(String.valueOf(i)); } l.sort((s1, s2) -> numericCompare(s1, s2, _flagi)); - list = (List) l; + list = l; } else if (flaga) { @@ -1712,7 +1711,7 @@ public class Expander extends BaseTokeni l.add(String.valueOf(i)); } l.sort(comparator); - list = (List) l; + list = l; } if (flagO) { @@ -1781,7 +1780,7 @@ public class Expander extends BaseTokeni { if (flagExpand && val instanceof List) { - val = new ArgList((List) val); + val = new ArgList((List<?>) val); } } @@ -2103,9 +2102,9 @@ public class Expander extends BaseTokeni } @SuppressWarnings("unchecked") - private Collection<Object> asCollection(Object val) + private <T> Collection<T> asCollection(Object val) { - return (Collection) val; + return (Collection<T>) val; } private Collection<Object> toCollection(Object val) { @@ -2117,7 +2116,7 @@ public class Expander extends BaseTokeni @SuppressWarnings("unchecked") private Map<Object, Object> asMap(Object val) { - return (Map) val; + return (Map<Object, Object>) val; } private List<Object> toList(Map<Object, Object> val1, boolean flagk, boolean flagv) Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Expression.java Wed Dec 19 22:29:43 2018 @@ -486,7 +486,7 @@ public class Expression { * Operand 2. * @return The result of the comparison. */ - public abstract boolean compare(Comparable v1, Comparable v2); + public abstract boolean compare(Comparable<?> v1, Comparable<?> v2); } /** @@ -787,10 +787,10 @@ public class Expression { addOperator(new Operator("**", 40, false) { @Override public BigDecimal eval(BigDecimal v1, BigDecimal v2) { - /*- - * Thanks to Gene Marin: - * http://stackoverflow.com/questions/3579779/how-to-do-a-fractional-power-on-bigdecimal-in-java - */ + /*- + * Thanks to Gene Marin: + * http://stackoverflow.com/questions/3579779/how-to-do-a-fractional-power-on-bigdecimal-in-java + */ int signOf2 = v2.signum(); double dn1 = v1.doubleValue(); v2 = v2.multiply(new BigDecimal(signOf2)); // n2 is now positive @@ -827,42 +827,42 @@ public class Expression { }); addOperator(new Comparator(">", 10) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) > 0; } }); addOperator(new Comparator(">=", 10) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) >= 0; } }); addOperator(new Comparator("<", 10) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) < 0; } }); addOperator(new Comparator("<=", 10) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) <= 0; } }); addOperator(new Comparator("==", 7) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) == 0; } }); addOperator(new Comparator("!=", 7) { - @Override @SuppressWarnings("unchecked") + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public boolean compare(Comparable v1, Comparable v2) { return v1.compareTo(v2) != 0; } @@ -1004,10 +1004,10 @@ public class Expression { addFunction(new Function("SQRT", 1) { @Override public BigDecimal eval(List<BigDecimal> parameters) { - /* - * From The Java Programmers Guide To numerical Computing - * (Ronald Mak, 2003) - */ + /* + * From The Java Programmers Guide To numerical Computing + * (Ronald Mak, 2003) + */ BigDecimal x = parameters.get(0); if (x.compareTo(BigDecimal.ZERO) == 0) { return new BigDecimal(0); Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java Wed Dec 19 22:29:43 2018 @@ -486,7 +486,7 @@ public class Pipe implements Callable<Re List<Path> paths = new ArrayList<>(); if (val instanceof Collection) { - for (Object o : (Collection) val) + for (Object o : (Collection<?>) val) { Path p = toPath(o); if (p != null) Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Reflective.java Wed Dec 19 22:29:43 2018 @@ -400,7 +400,7 @@ public final class Reflective * 1. prefer f() to f(T[]) with empty array * 2. prefer f(T) to f(T[1]) * 3. prefer f(T) to f(Object[1]) even if there is a conversion cost for T - * + * * 1 & 2 require to add 1 to conversion cost, but 3 also needs to match * the conversion cost for T. */ @@ -437,7 +437,7 @@ public final class Reflective if (type.isArray() && arg instanceof Collection) { - Collection col = (Collection) arg; + Collection<?> col = (Collection<?>) arg; return col.toArray((Object[]) Array.newInstance(type.getComponentType(), col.size())); } @@ -556,7 +556,7 @@ public final class Reflective StringBuilder sb = new StringBuilder(); sb.append("["); boolean first = true; - for (Object o : ((Collection) arg)) + for (Object o : ((Collection<?>) arg)) { if (!first) { sb.append(" "); Modified: felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java (original) +++ felix/trunk/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/activator/Activator.java Wed Dec 19 22:29:43 2018 @@ -45,15 +45,15 @@ public class Activator implements Bundle { protected CommandProcessorImpl processor; private ThreadIOImpl threadio; - private ServiceTracker commandTracker; - private ServiceTracker converterTracker; - private ServiceTracker listenerTracker; - private ServiceRegistration processorRegistration; - private ServiceRegistration threadioRegistration; - + private ServiceTracker<?,?> commandTracker; + private ServiceTracker<?,?> converterTracker; + private ServiceTracker<?,?> listenerTracker; + private ServiceRegistration<?> processorRegistration; + private ServiceRegistration<?> threadioRegistration; + public static final String CONTEXT = ".context"; - protected ServiceRegistration newProcessor(ThreadIO tio, BundleContext context) + protected ServiceRegistration<?> newProcessor(ThreadIO tio, BundleContext context) { processor = new CommandProcessorImpl(tio); try @@ -81,7 +81,7 @@ public class Activator implements Bundle threadioRegistration = context.registerService(ThreadIO.class.getName(), threadio, null); processorRegistration = newProcessor(threadio, context); - + commandTracker = trackOSGiCommands(context); commandTracker.open(); @@ -134,7 +134,7 @@ public class Activator implements Bundle processor.stop(); } - private ServiceTracker trackOSGiCommands(final BundleContext context) + private ServiceTracker<?,?> trackOSGiCommands(final BundleContext context) throws InvalidSyntaxException { Filter filter = context.createFilter(String.format("(&(%s=*)(%s=*))", Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java (original) +++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/AbstractParserTest.java Wed Dec 19 22:29:43 2018 @@ -19,7 +19,6 @@ package org.apache.felix.gogo.runtime; import java.io.FilterInputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintStream; Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java (original) +++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/ReflectiveTest.java Wed Dec 19 22:29:43 2018 @@ -24,7 +24,6 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.*; -import org.apache.felix.service.command.CommandProcessor; import org.apache.felix.service.command.CommandSession; import org.apache.felix.service.command.Converter; import org.junit.Assert; Modified: felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java (original) +++ felix/trunk/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestTokenizer.java Wed Dec 19 22:29:43 2018 @@ -124,7 +124,7 @@ public class TestTokenizer assertEquals("\n", t.next().toString()); assertNull(t.next()); } - + @Test public void testString() throws Exception { @@ -530,6 +530,7 @@ public class TestTokenizer assertNull(t.next()); } + @SuppressWarnings({ "rawtypes", "unchecked" }) private BundleContext createMockContext() throws ClassNotFoundException { Bundle systemBundle = mock(Bundle.class); Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java (original) +++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Activator.java Wed Dec 19 22:29:43 2018 @@ -29,7 +29,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import org.apache.felix.service.command.CommandProcessor; @@ -44,8 +43,8 @@ import org.osgi.util.tracker.ServiceTrac public class Activator implements BundleActivator { private BundleContext context; - private ServiceTracker commandProcessorTracker; - private Set<ServiceRegistration> regs; + private ServiceTracker<?,?> commandProcessorTracker; + private Set<ServiceRegistration<?>> regs; private volatile ExecutorService executor; private volatile StartShellJob shellJob; @@ -62,14 +61,14 @@ public class Activator implements Bundle } public void stop(BundleContext context) { - Set<ServiceRegistration> currentRegs; + Set<ServiceRegistration<?>> currentRegs; synchronized (regs) { currentRegs = new HashSet<>(regs); regs.clear(); } - for (ServiceRegistration reg : currentRegs) + for (ServiceRegistration<?> reg : currentRegs) { reg.unregister(); } @@ -105,7 +104,7 @@ public class Activator implements Bundle Dictionary<String, Object> dict = new Hashtable<>(); dict.put(CommandProcessor.COMMAND_SCOPE, "gogo"); - Set<ServiceRegistration> currentRegs = new HashSet<>(); + Set<ServiceRegistration<?>> currentRegs = new HashSet<>(); // register converters currentRegs.add(context.registerService(Converter.class.getName(), new Converters(context.getBundle(0).getBundleContext()), null)); Modified: felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Converters.java URL: http://svn.apache.org/viewvc/felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Converters.java?rev=1849342&r1=1849341&r2=1849342&view=diff ============================================================================== --- felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Converters.java (original) +++ felix/trunk/gogo/shell/src/main/java/org/apache/felix/gogo/shell/Converters.java Wed Dec 19 22:29:43 2018 @@ -31,7 +31,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.ServiceReference; -import org.osgi.service.startlevel.StartLevel; +import org.osgi.framework.startlevel.BundleStartLevel; public class Converters implements Converter { @@ -45,27 +45,13 @@ public class Converters implements Conve private CharSequence print(Bundle bundle) { // [ ID ] [STATE ] [ SL ] symname - StartLevel sl = null; - ServiceReference ref = context.getServiceReference(StartLevel.class.getName()); - if (ref != null) - { - sl = (StartLevel) context.getService(ref); - } - - if (sl == null) - { - return String.format("%5d|%-11s|%s (%s)", bundle.getBundleId(), - getState(bundle), bundle.getSymbolicName(), bundle.getVersion()); - } - - int level = sl.getBundleStartLevel(bundle); - context.ungetService(ref); + int level = bundle.adapt(BundleStartLevel.class).getStartLevel(); return String.format("%5d|%-11s|%5d|%s (%s)", bundle.getBundleId(), getState(bundle), level, bundle.getSymbolicName(), bundle.getVersion()); } - private CharSequence print(ServiceReference ref) + private CharSequence print(ServiceReference<?> ref) { String spid = ""; Object pid = ref.getProperty("service.pid"); @@ -188,7 +174,7 @@ public class Converters implements Conve String s = in.toString(); if (s.startsWith("(") && s.endsWith(")")) { - ServiceReference refs[] = context.getServiceReferences((String) null, String.format( + ServiceReference<?> refs[] = context.getServiceReferences((String) null, String.format( "(|(service.id=%s)(service.pid=%s))", in, in)); if (refs != null && refs.length > 0) { @@ -196,7 +182,7 @@ public class Converters implements Conve } } - ServiceReference refs[] = context.getServiceReferences((String) null, String.format( + ServiceReference<?> refs[] = context.getServiceReferences((String) null, String.format( "(|(service.id=%s)(service.pid=%s))", in, in)); if (refs != null && refs.length > 0) { @@ -248,7 +234,7 @@ public class Converters implements Conve } if (level == LINE && target instanceof ServiceReference) { - return print((ServiceReference) target); + return print((ServiceReference<?>) target); } if (level == PART && target instanceof Bundle) { @@ -256,7 +242,7 @@ public class Converters implements Conve } if (level == PART && target instanceof ServiceReference) { - return getShortNames((String[]) ((ServiceReference) target).getProperty("objectclass")); + return getShortNames((String[]) ((ServiceReference<?>) target).getProperty("objectclass")); } return null; }
