Trouble with  instantiating inherited classes in a switch statement

Hi
I have few inherited classes which I need to instantiate in a switch statement based on command line argument supplied by user. I am ble to do that but I cannot access any methods once I come out of the switch scope. Please suggest a way to resolve this problem. The error I am getting is in the end of code in comments // //. Would really appreciate your help.
Thanks
Here is the code.
package assignment2;
import java.util.*;
import java.io.*;
abstract class Parent
abstract void childclassDescription();
void generalDescriptionToAllChilds()
System.out.println("general to all child classes");
childclassDescription();
class Child1 extends Parent
public void childclassDescription()
System.out.println("i'm child1");
class Child2 extends Parent
public void childclassDescription()
System.out.println("i'm child2");
class Child3 extends Parent
public void childclassDescription()
System.out.println("i'm child3");
public class Demo
public static void main(String[] args)
int option;
Parent p;
System.out.println("Pick from one of the following:");
option=1; // supplying
switch(option)
case 1:
p=new Child1();
break;
case 2:
p=new Child2();
break;
case 3:
p=new Child3();
default:
break;
p.generalDescriptionToAllChilds();
//error variable p might not have been initialized at line //
}

Well I also think that in Java, it is possible for a reference type variable to refer to nothing at all. A reference that refers to nothing at all is called a null reference . By default, an uninitialized reference is null.
We can explicitly assign the null reference to a variable like this:
f = null;
But still i am not quety sure why you needed to do it.

Similar Messages

  • More trouble with the robot class (takin a screencapture)

    I have created a small label which can have a transaprent background, and through the help of people on this forum, I am tryin to make it more robust. My latest task involves adding a component listener, and changing the background image when the parent component is moved.
    Unfortunately, the background image is not being changed, but I dont know why. When I slow things down with a debugger, it seems that all of my x and y coordinates are correct, but the background image remains the same.
    If you give it a shot, you will be able to see what I mean:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    public class LabelTest extends JWindow {
         static int x=300, y=300;
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              frame.setPreferredSize(new Dimension(300,400));
              final LabelTest l = new LabelTest(frame, new Point(500,500), "My long string 222333111444555");
              l.setFont(new Font("Tahoma", Font.BOLD, 14));
              frame.addComponentListener(new ComponentAdapter() {
                   public void componentMoved(ComponentEvent e) {
                        x+=5;
                        y+=5;
                        l.setLocation(x,y);
              frame.pack();
              frame.setVisible(true);
              l.setVisible(true);
         private BubbleLabel bubble;
         public LabelTest(JFrame owner, Point startingPoint, String text) {
              super(owner);
              setupBubble(startingPoint, text);
         public LabelTest(JDialog owner, Point startingPoint, String text) {
              super(owner);
              setupBubble(startingPoint, text);
         private void setupBubble(Point startingPoint, String text) {
              bubble = new BubbleLabel(startingPoint, text);
              this.setLocation(startingPoint);
              this.setLayout(new BorderLayout());
              this.add(bubble, BorderLayout.CENTER);
              this.pack();
         public void setFont(Font f) {
              bubble.setFont(f);
              this.pack();
         public void setLocation(int x, int y) {
              super.setLocation(x,y);
              bubble.updatePoint(x, y);
         public class BubbleLabel extends JLabel {
              private String myText;
            private BufferedImage image;
              private Point point;
              private Robot robot;
              public BubbleLabel(Point p, String text) {
                   this.point = p;
                   this.myText = text;
                   try {
                        robot = new Robot();
                   catch(AWTException e) {
                        e.printStackTrace();
                   setupImage();
              public void updatePoint(int x, int y) {
                   this.point = new Point(x,y);
                   setupImage();
              private void setupImage() {
                   if(point ==  null) {
                        return;
                   try {
                        Dimension d = getPreferredSize();
                        image = robot.createScreenCapture(new Rectangle(point.x, point.y, d.width, d.height));
                   catch(Exception e){
                        e.printStackTrace();
              public void setFont(Font f) {
                   super.setFont(f);
                   setupImage();
              public void paint(Graphics g) {
                   Graphics2D g2 = (Graphics2D)g;
                   g2.drawImage(image,0,0,this);
                   //draw the labels
                   Font f = getFont();
                   if(f != null) {
                        FontMetrics fm = getFontMetrics(getFont());
                        g2.setColor(Color.GREEN);
                        g2.drawString(myText, 15, 25 + fm.getHeight()/2 - fm.getMaxDescent());
              public Dimension getPreferredSize() {
                   Font f = getFont();
                   if(f != null) {
                        FontMetrics fm = getFontMetrics(getFont());
                        int hieght = fm.getHeight();
                        int width = 0;
                        width = fm.stringWidth(myText);
                        System.err.println(width + 15);
                        return new Dimension(width + 15, hieght + fm.getHeight()*2);
                   else {
                        return new Dimension(200, 200);
              public Dimension getMinimumSize() { return new Dimension(200, 200); }
    }

    Hi camickr,
    I didn't ignore your suggestions, I just didn't completely understand them (I actually asked about them in my previous thread, but didn't get a response). Looking back at that thread, I realize that I read some of the code wrong. Where it saide desktopImage != null I saw desktopImage == null in the paintComponent() method. Now that I have reread it, I understand what you were getting at. However, that still doesn't solve the problem of the background changing. i.e. a screen behind my application is minimized.
    As for your suggestions:
    a) Right you are, I should be using paintComponent. I normally don't make this mistake, but I have been playing with so many different variations of this code, in different classes, that things have gotten quite mixed up. You also have to understand, that the code I posted is much smaller than the code I am working with, in order to be able to identify exactly what problem I am having, and not give you guys the burden of sorting through a lot of unrelevant code.
    b) right you are again. I started with the JLabel, because I was going to use some of the class's properties, but as my code has progressed, I have steered away from that approach. However, for my puproses I don't see the downside of using it. I want to get my core functionality working, and then clean the code up.
    c) see first paragraph
    d) I haven't looked into it, but I am not so sure this would work for my purposes. I use the graphics package to draw a border around the text (I cant use the border classes because this is not a uniform border). I suppose this is more reason to use a JComponent than a JLabel.
    e) The is no real logic to my component listener. I wrote it to show the problem I am having. I just increased the pixels by 5 for each call, because that was the simplest way to show that the background image was not being 1) created correctly or 2) painted correctly. As I said before, I want to solve the core issues first, then clean up the code so it actually behaves in a manner that makes sense.
    I don't know why the code didn't execute for you. Are you just not seing the text at 500,500? It should say: "My long string 222333111444555" in Green, with a transparent background (i.e. the screenshot of the background image.
    Thanks for your suggestions. I appreciate your help!

  • Update of photoshop CC - trouble with NVIDIA Quadro 1000M display driver. PS freezes

    Hey guys,
    Since today I've got trouble with my PS CC.
    I've updated PS CC yesterday 2014-12-12.
    I was doing some drawings today and two times PS freezes during switching layers of or selecting a mask.
    A message appeared that there was trouble with the display driver an PS switched off the GPU support because of that issue.
    Ok, I thought let's update the display driver and so I've done today. I switched to actual NVIDIA display driver version 314.21
    I'm working with an NVIDIA Quadro 1000M on a DELL mobile Workstation Precision M4600 with 8 GB RAM.
    Now when I start up PS and press alt+k, my 2 displays showing a black screen for 1-2 seconds.
    After closing the general setup window again black screen for 1-2 sec and the top menu bar is showing no entries.
    When I move the mouse pointer over the bar, the menus appear again. But the bar is like transparent at the parts where no menues are.
    When I unlock the window from the screen an put it back fitting to the screen everything looks like normal.
    Till today I hadn't any problem with my notebook in that kind of way.
    Maybe someone has or had similar problems.
    Would be nice if someone can help me.
    thanks

    Oh, that sounds very bad. It's not that bad for me. It's not crashing that often at the moment, only black screens at start up or if setting dialog is opened. But I will see tomorrow how often it will crash, during today it crashed 2 times when doing some ridiculous simple actions like switchid to another layer  and the other time when trying to edit an mask layer. I will contact the support chat on monday regarding this issue. Maybe there is a solution or an update soon... I keep may fingers crossed for you.

  • I'm having trouble with my Apple ID. I changed my email account, and recently (a month ago) and since I switched is requested every time I open any app to Apple ID password to the old email. How can I solve this? Could it be that my iPhone 4S is in sync w

    I'm having trouble with my Apple ID. I changed my email account, and recently (a month ago) and since I switched is requested every time I open any app to Apple ID password to the old email. How can I solve this? Could it be that my iPhone 4S is in sync with my Ipod???

    If you updated your existing account then try logging out of it on the iPhone by tapping on the id in Settings > iTunes & App Stores and then log back in and see if that 'refreshes' the account on the iPhone. If you created a new account then any content that you purchased/downloaded via the old account will remain tied to that old account, and only that old account can download updates to its apps.

  • Trouble with class

    I am unable to figure out what I am having trouble with this, here is the code
    public class Tools3
        protected long item_number;
        protected String product_name;
        protected long units_in_stock;
        protected double price_of_each_unit;
        protected static double total_price_of_inventory;
    public Tools3( long pitem_number, String pproduct_name, long punits_in_stock, double pprice_of_each_unit)
       item_number = pitem_number;
       product_name = pproduct_name;
       units_in_stock = punits_in_stock;
       price_of_each_unit = pprice_of_each_unit;
       total_price_of_inventory = punits_in_stock * pprice_of_each_unit;
    // Overloaded constructor for empty balance
    public Tools3()
       item_number = 0;
    public void set_item_number( long pitem_number )
       item_number = pitem_number;
    public void set_product_name( String pproduct_name )
       product_name = pproduct_name.toString();
    public void set_units_in_stock( long punits_in_stock )
       units_in_stock = punits_in_stock;
    public void set_price_of_each_unit( double pprice_of_each_unit )
       price_of_each_unit = pprice_of_each_unit;
    public long get_item_number()
       return item_number;
    public String get_product_name()
       return product_name;
    public long get_units_in_stock()
       return units_in_stock;
    public double get_price_of_each_unit()
       return price_of_each_unit;
    public double calculate_total_price()
       return units_in_stock * price_of_each_unit;
    public double calculate_total_price_of_inventory(Tools3[] mytools)
       double rettotal = 0;
       for (int i = 0; i < mytools.length; i++)
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_each_unit());
       return rettotal;
      public void sort_by_names(Tools3[] mytools)
      int a,b;
      int sortTheStrings = mytools.length - 1;
      String tempproduct_name;
      long tempitem_number;
      long tempunits_in_stock;
      double tempprice_of_each_unit;
        //need to implement a bubble sort here
        for (a = 0; a < sortTheStrings; ++a)
      for (b = 0; b < sortTheStrings; ++b)
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
        //move name
        tempproduct_name = mytools.product_name;
        mytools.product_name = mytools[b+1].product_name;
        mytools[b+1].product_name = tempproduct_name;
        //move item_number
        tempitem_number = mytools.item_number;
        mytools.item_number = mytools[b+1].item_number;
        mytools[b+1].item_number = tempitem_number;
        //move units_in_stock
        tempunits_in_stock = mytools.units_in_stock;
        mytools.units_in_stock = mytools[b+1].units_in_stock;
        mytools[b+1].units_in_stock = tempunits_in_stock;
        //move price_of_each_unit
        tempprice_of_each_unit = mytools.price_of_each_unit;
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
        mytools[b+1].price_of_each_unit = tempprice_of_each_unit;
    //end of tools3.java class

    Results from javac
    C:\Java>javac Tools3.java
    Tools3.java:77: cannot find symbol
    symbol  : method get_units_in_stock()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                      ^
    Tools3.java:77: cannot find symbol
    symbol  : method get_price_of_each_unit()
    location: class Tools3[]
        rettotal = rettotal + (mytools.get_units_in_stock() * mytools.get_price_of_e
    ach_unit());
                                                                     ^
    Tools3.java:94: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
      if(mytools.product_name.compareTo(mytools[b + 1].product_name) >0)
                ^
    Tools3.java:97: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        tempproduct_name = mytools.product_name;
                                  ^
    Tools3.java:98: cannot find symbol
    symbol  : variable product_name
    location: class Tools3[]
        mytools.product_name = mytools[b+1].product_name;
               ^
    Tools3.java:101: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        tempitem_number = mytools.item_number;
                                 ^
    Tools3.java:102: cannot find symbol
    symbol  : variable item_number
    location: class Tools3[]
        mytools.item_number = mytools[b+1].item_number;
               ^
    Tools3.java:105: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        tempunits_in_stock = mytools.units_in_stock;
                                    ^
    Tools3.java:106: cannot find symbol
    symbol  : variable units_in_stock
    location: class Tools3[]
        mytools.units_in_stock = mytools[b+1].units_in_stock;
               ^
    Tools3.java:109: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        tempprice_of_each_unit = mytools.price_of_each_unit;
                                        ^
    Tools3.java:110: cannot find symbol
    symbol  : variable price_of_each_unit
    location: class Tools3[]
        mytools.price_of_each_unit = mytools[b+1].price_of_each_unit;
               ^
    11 errors

  • If i made an appt. with Apple, and i asked them if i could switch my black Iphone 5 to a white Iphone 5, because i always have trouble with black Iphones, would they let me?

    if i made an appt. with Apple, and i asked them if i could switch my black Iphone 5 to a white Iphone 5, because i always have trouble with black Iphones, would they let me?

    i've had black iphones in the past, and the same thing always gets messed up, the network, i will not have service what-so ever, and when my mother's iphone will be right next to me and she will have full service. Also the lock screen button/power button broke on both of my black iphones as well. i was just wondering if they would consider. Does apple have an email i could contact?

  • Switched from a PC to a MBP, having trouble with iTunes syncing iPhones, iPods. Devices are still linked to the PC ?

    Switched from a PC to a MBP, having trouble with iTunes syncing iPhones, iPods. Devices are still linked to the PC. How do I undo the PC link without a restore / reformat?

    Post in the iTunes forum:
    https://discussions.apple.com/community/itunes
    Read:
    http://www.apple.com/support/switch101/
    http://www.macworld.com/article/1153952/superguide_switchingtoamac.html

  • Errors with CF 8.0.1 hotfix 3 and hotfix 4, "Object Instantiation Exception.Class not found"

    We need to get our servers up to date with the latest ColdFusion hotfixes in order to pass our security scans and policies. We have been following the Adobe instructions for installing the hotfixes, but we’re getting the same errors each time. The CF 8 hotfix 2 works fine, but once we install hotfix 3 and/or hotfix 4, we get the following errors:
    "Object Instantiation Exception.Class not found: coldfusion.security.ESAPIUtils The specific sequence of files included or processed is: C:\ColdFusion\wwwroot\WEB-INF\exception\java\lang\Exception.cfm, line: 12 "
    coldfusion.runtime.java.JavaObjectClassNotFoundException:
    We have dozens of servers running Windows XP, Netscape Enterprise Server 6.1 (I  know, don’t laugh), ColdFusion 8,0,1,195765, and Java Version 1.6.0_04. Just about  the only good thing about running XP on our servers is that it matches  our development boxes, so we have almost mirrored environments for dev,  test, and production. We do NOT have the CF install with the J2EE configuration.
    The crazy thing is, on tech note 51180 (http://kb2.adobe.com/cps/511/cpsid_51180.html), it says that the fix for bug # 71787 (Fix for "Object Instantiation Exception" thrown when calling a Java object constructor or method with a null argument under JDK 1.6.) was added in cumulative hotfix 2. However we don’t see this problem until we go to hotfix 3 (or 4).
    I’ve also been reading that other people had this same problem, and that the CF 8 hotfix 3 was not compatible with certain versions of JDK, then when you read the Adobe site for CF 8.0.1 hotfix 3, it says “Added the updated cumulative hotfix to make it compatible with jdk 1.4.x, 1.5.x and 1.6.x.”, so that makes me think that Adobe was supposed to have fixed this CF 8.0.1 hotfix 3 JDK incompatability issue - but unfortunately it's still not working for us. We have followed the instructions for removing the jar files and starting/restarting the CF server as directed, we’ve tried this 5-6 times, and still no luck.
    Recommendations? Seems like this is a ColdFusion bug to me – one that says is fixed on the Adobe site, but is not fixed in our environment. Please advise, thanks.

    For what it's worth, we had an MXUnit user describe a similar, though not identical, problem after installing the latest hotfixes. In his case, he's getting "NoSuchMethodExceptions".

  • I have Iphone 3g but I'm facing a huge trouble with it once it's discharged it doesn't switch on again even with it's own cable

    hii i have iphone 3g but i am facing a huge trouble with it.Once it's discharged it doesn't switch on again even if i connect it with electricity . what should i do?? please answer me.

    Hello manal1994,
    You may want to try resetting and, if necessary, restoring your iPhone.
    iPhone, iPad or iPod touch: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    If the device remains unresponsive or does not turn on (or power on), try resetting
    Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds.
    If there is no video, verify that the device has enough charge to turn on
    If you are using an iPad, ensure that it's connected to the 10W USB Power Adapter.
    Let charge for at least twenty minutes, then see if it starts normally.
    If there is no image on the screen, press the Home button to attempt to wake the device.
    If the screen displays a red battery icon, let the device to continue to charge until it turns on.
    If the above steps do not resolve the issue, or the if the screen remains black or shows a persistent Apple logo, try restoring with iTunes
    Connect the device to your computer and open iTunes.
    If the device appears in iTunes, select and click Restore on the Summary pane. Learn more about restoring iOS software.
    If the device doesn't appear in iTunes, try to force the device into recovery mode.
    All the best,
    Allen

  • Trouble with interface class

    Hi there,
    for a school project we're building a helicopter which can be controlled via the computer. We're going to connect some wires to the remote control of the helicopter and the wires we also connect to a LabJack (a digital/analog converter). Via java we can give signals to this labjack and control so the helicopter. Only one thing: I've downloaded the library for labjack for java. You can see this labrary, it called LabJackJava: http://www.teravation.com/downloads/LabJackJava.zip
    In it is a few classes and one of them is called LabJack (this is in fact a interface). In the interface there is a method called: void setAO(int channel, float value) throws LabJackException;
    This method I'm going to need to set the voltage on the wires. For compiling I use the program BlueJ (which is a object-orientated compiler). But because the the class LabJack is a interface, I cannot call the method setAO(). How can I solve this?? I also had some trouble with the System.loadLibrary("ljackj"); in the class LabJackDriver. I copied the file ljackj.dll into the folder system32 (windows) and it still doesn't work... Is this dll essential for the working of the class LabJack??? How can I solve this???
    Please help me!!
    Thanks!
    Héctor van den Boorn

    This is a forum for the Java programming language, not for every program and library ever written in Java. The LabJack site has a support area and forum, which should be the right place to seek a solution.
    That said, the documentation indicates that you obtain a LabJack reference from the appropriate method of LabJackFactory. The reference returned will be that of a platform dependent concrete class that implements the interface.
    db
    edit Oh, I see you have a history of not replying to responses on your posts. This was exceptionally bad, 9 responses and not a peep out of you.
    [http://forums.sun.com/thread.jspa?threadID=5242071]
    Fine. One for the blacklist.
    Edited by: Darryl.Burke

  • Hi i am havin trouble with my ipad after i have downloaded a game and have been playing for a while it seems to of diapeared and the screen goes a white blank background there is nothing on the screen at all so i switch it off and back on and it is white

    hi i am having trouble with games on my ipad as i have been playing them the screen goes white and i can't play the game i go back to the game centre on the ipad and click on the icon for the game and come up to play i push play buton and the screen come up again white so any body had the same problem could they let me no thanks

    Quit the game and restart the iPad.
    To quit the game - Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    If that doesn't work try this.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • Dynamic loading of a class at runtime with known inheritance

    Hi,
    I am trying to dynamically load a class during runtime where I know that the class implements a particular interface 'AInterface'. Also, this class may be linked to other classes in the same package as that class, with their implementations/extensions given in their particular definitions.
    The class is found by using a JFileChooser to select the class that implements 'AInterface', and loaded up.
    Because the name of the class can be practically anything, my current approach only works for certain classes under the package 'Foo' with classname 'Bar'. Some names have been changed to keep it abstract.
    private AInterface loadAInterface(URL url) throws Exception {
         URL[] urls = { url };
         // Create a new class loader with the directory
         URLClassLoader cl = new URLClassLoader(urls);
         // Load in the class
         Class<?> cls = cl.loadClass("Foo.Bar");
         return (AInterface) cls.newInstance();
    }As you can see, all that is being returned is the interface of the class so that the interface methods can be accessed. My problem is that I don't know what the class or package is called, I just know that the class implements AInterface. Also note that with this approach, the class itself isn't selected in the JFileChooser, rather the folder containing Foo/Bar.class is.

    ejp wrote:
    The class is found by using a JFileChooser to select the class that implements 'AInterface', and loaded up.
    Also note that with this approach, the class itself isn't selected in the JFileChooser, rather the folder containing Foo/Bar.class is.These two statements are mutually contradictory...My apologies, I worded that wrong. My current approach (the one given in the code) selects the root package folder. However, what I want to be able to do, is to simply select a single class file. The current code just makes some assumptions so that I can at least see results in the program.
    As you said, if the root of the package hierarchy is known, then this could be achieved. The problem is that the user either selects the package root or the AInterface class, but not both.
    Is there a way to get package details from a .class file to be used in the actual loading of the class?

  • X-Fi Xtereme Music mode switching and troubles with channels redirection

    Good Day.
    I have bought a X-Fi sound card and now I have troubles with my speaker system. I have analog stereo system and headphones, I connect them using my amplifier. All cables are connected properly.
    When I use entertainment mode there are no problems with speaker system if 2.0/2.1 is set. But if I set headphones channels become redirected: left becomes right and right becomes left.
    When i use game mode channels are redirected both in 2.0/2.1 and headphones modes.
    If I connect my headphones to sound card directly there are no problems excepting entertainment mode 2.0/2.1 when channels are redirected.
    Please halp me to resolve the problem.
    Thank you.

    Don`t care. I have found the way. Now all clear.:smileyvery-happy:

  • Having trouble with First Class mail

    I'm trying to use my email at school (Benito Juarez Community Academy) and also set up Gradespeed but having trouble with both.
    In composing mail, the screen will only accept a line or so and no more. I can mail that but message is incomplete. Also, can't get into Gradespeed. All I get is a multicolored pinwheel that is a security check but never stops spinning.

    See this thread: [[/en-US/questions/894442]] OWA 2010/Firefox 8 and ASHX Attachments

  • Trouble with Toshiba built-in webcam: "unable to enumerate USB device"

    I am running archlinux on a Toshiba Satellite L70-B-12H laptop, and having troubles with the Webcam. *Once in a while*, everything goes well and I get
    # lsusb
    Bus 004 Device 002: ID 8087:8000 Intel Corp.
    Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 004: ID 04f2:b448 Chicony Electronics Co., Ltd
    Bus 003 Device 003: ID 8087:07dc Intel Corp.
    Bus 003 Device 002: ID 8087:8008 Intel Corp.
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    # dmesg
    [ 3433.456115] usb 3-1.3: new high-speed USB device number 4 using ehci-pci
    [ 3433.781119] media: Linux media interface: v0.10
    [ 3433.809842] Linux video capture interface: v2.00
    [ 3433.826889] uvcvideo: Found UVC 1.00 device TOSHIBA Web Camera - HD (04f2:b448)
    [ 3433.835893] input: TOSHIBA Web Camera - HD as /devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.3/3-1.3:1.0/input/input15
    [ 3433.835976] usbcore: registered new interface driver uvcvideo
    [ 3433.835977] USB Video Class driver (1.1.1)
    Unfortunately, *most of the time* the camera seems invisible to my system, and I get
    # lsusb
    Bus 004 Device 002: ID 8087:8000 Intel Corp.
    Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 003: ID 8087:07dc Intel Corp.
    Bus 003 Device 002: ID 8087:8008 Intel Corp.
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    (note the missing "04f2:b448 Chicony Electronics Co., Ltd" device), and
    # dmesg
    [ 480.104252] usb 3-1.3: new full-speed USB device number 4 using ehci-pci
    [ 480.171097] usb 3-1.3: device descriptor read/64, error -32
    [ 480.341235] usb 3-1.3: device descriptor read/64, error -32
    [ 480.511375] usb 3-1.3: new full-speed USB device number 5 using ehci-pci
    [ 480.578007] usb 3-1.3: device descriptor read/64, error -32
    [ 480.748151] usb 3-1.3: device descriptor read/64, error -32
    [ 480.918282] usb 3-1.3: new full-speed USB device number 6 using ehci-pci
    [ 481.325196] usb 3-1.3: device not accepting address 6, error -32
    [ 481.392091] usb 3-1.3: new full-speed USB device number 7 using ehci-pci
    [ 481.798926] usb 3-1.3: device not accepting address 7, error -32
    [ 481.799166] hub 3-1:1.0: unable to enumerate USB device on port 3
    Searching on the web, most results I found lead to this page, where it is said that the problem is due to badly tuned overcurrent protection, and advocated that unplugging and switching off the computer for a little while gets things back into normal. This does not really work for me; the problem seems to occur more randomly, unfortunately with high probability (my camera is available after less than one boot out of ten).
    I tried to ensure that the ehci-hcd module is loaded at boot with the ignore-oc option (with a file in /etc/module-load.d/), to no avail.
    I also wrote a script which alternatively removes and reloads the ehci-pci driver until my device is found in lsusb. It is sometimes helpful, but usually not. And even when my device is found that way, it can only be used for a while before disappearing again.
    Anyway, such a hack is unacceptable... So, my questions are:
    is it indeed related to overcurrent protection ?
    is there anything else I can try ?
    should I file somewhere an other of the numerous bug reports about "unable to enumerate USB device" already existing ?
    If of any importance, I am running linux 3.15.7, because at the time I installed my system, I couldn't get the hybrid graphic card Intel/AMD working under 3.16.
    Last edited by $nake (2014-10-18 16:29:06)

    uname -a
    Linux libra 3.9.4-1-ARCH #1 SMP PREEMPT Sat May 25 16:14:55 CEST 2013 x86_64 GNU/Linux
    pacman -Qi linux
    Name : linux
    Version : 3.9.4-1
    Description : The linux kernel and modules
    Architecture : x86_64
    URL : http://www.kernel.org/
    Licences : GPL2
    Groups : base
    Provides : kernel26=3.9.4
    Depends On : coreutils linux-firmware kmod mkinitcpio>=0.7
    Optional Deps : crda: to set the correct wireless channels of your country
    Required By : nvidia
    Optional For : None
    Conflicts With : kernel26
    Replaces : kernel26
    Installed Size : 65562.00 KiB
    Packager : Tobias Powalowski <[email protected]>
    Build Date : Sat 25 May 2013 16:28:17 CEST
    Install Date : Sun 02 Jun 2013 15:30:35 CEST
    Install Reason : Explicitly installed
    Install Script : Yes
    Validated By : Signature

Maybe you are looking for