Searching for unnecessary typecasts

Are there any tools that can read my code and find unnecessary typecasts?
I'm in the process of upgrading all my code to use generics. I'm very pleased at the number of typecasts I'm eliminating. Since I'm doing it manually, though, I bet I'm leaving in a lot of unnecessary (and potentially unsafe) casts. It would be great to have to tool that would find all these.

You're asking if the compiler will complain when I
make a necessary cast? Of course not.In 1.5, don't you get a warning about an unsafe cast?
The only time it wouldn't do that in 1.5 is if you
didn't really need the cast, right? Maybe, I'm
missing something.Ooops. Let me try that again...
I see. You 're talking about unsafe casts. I'm talking unnecessary. I've got tons of code that does something like this:
        ArrayList colors;
        return (Color) colors.get(0); // Casts from Object to Color.In moving to 1.5 I'm making the container generic.
        ArrayList<Color> colors;
        return (Color) colors.get(0); // Casts from Color to Color.  Unneeded. I wanted these compiler warnings to be tell me that the cast there is unnecessary and should be removed.
        ArrayList<Color> colors;
        return colors.get(0); // No cast. Joy.

Similar Messages

  • Any way to search for casts in java source code?

    Anyone know of a decent way to search your java source files to find all the casts?
    I ended up doing a simple text search for
         " = ("(quote marks not included) which works for my code because I am strict about writing my casts with spaces like
         String s = (String) iterator.next();Unfortunately, the above search has all kinds of problems with both false positives and negatives. It picks up lots of irrelevant lines like
         int index = (number > 0) ? 0 : 1;as well as misses casts that appear nested inside expressions like
         ((String) iter.next()).charAt(...)I suppose that one could do a regular expression search for any pair of open and close parens which bound non-blank text, but that would pick up even more non-cast expressions in typical java code.
    I think that the only way to properly do this is to have a tool which understands java syntax.
    Anyone know of an IDE which will do this? Does IntelliJ or Netbeans support this kind of search?
    In case you are wondering why I am interested in this, it is because I am refactoring some code to fully use generics, and searching for casts is one source of identifying candidates for genericity.

    cliffblob wrote:
    Better late than never?Yes!
    cliffblob wrote:
    ...The answer I found to ID unnecessary casts was, using Eclipse IDE, In compiler error and warning preferences to warn on unnecessary casts.Thanks for pointing IDEs out. I just opened IntelliJ, and going back to at least version 7.04 (maybe earlier) they have an inspection for "Redundant type cast".
    cliffblob wrote:
    I would still be interested to know if there is a way to identify casts in general in your source, perhaps now four years later there is a way?The only solutions that I can think of are either a complicated regex search, or you must use some tool like an IDE that understand Java syntax and can determine if a cast is happening.

  • Search for end-of-paragraph before end of story? CS6

    Hi,
    Does anybody know of a way to search for a paragraph mark directly
    before an end of story marker? I'd like to get rid of them, e.g., in
    footnotes, where the last paragraph mark causes an unnecessary blank line.
    Thanks,
    Ariel

    I found \z on Mike Witherell's great little chart at http://www.jetsetcom.net/useful-resources/indesign-cs6-resources.html
    End of paragraph, at least in GREP is a location, not a character (the metacharacter is $) and can't be selected or replaced. Every paragraph has one. Paragraphs before the end of story also have a paragaph break, and that's what you are trying to remove at the end of your footnote story.
    @David, Why bother withthe lookahead? \z is the location, so I would presume that the search would start at the end of story and look at the last character. That has to be faster than parsing every break in the paragraph to check for the end of story location after, and there's no possibility that you will actually delete the EOS since it can't actually be selected.

  • Grep Removing Characters when searching for Paragraph returns

    I'm currently working on an xml based business card file and the formatting requires me to search for a phone number followed by a End of Paragraph followed by a Page Break and then remove the unnecessary Paragraph Return. For some reason inDesign will not find an End of Paragraph then a Page Break through the following grep code "\r~P", however if I search for "\r\r" it will find it. I have been able to get this to work with "(\d{3}\.\d{3}.\d{4})\r\r" and then change to "$1~P", but each subsequent business card loses one number off of the end (804.777.7777, 804.777.777, 804.777.77 etc). What would cause this?
    Thank you,
    Brandon Boswell

    You should move this over to scripting (http://forums.adobe.com/community/indesign/indesign_scripting). You'll find people over there who can give you more help, if there is any.

  • I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac.  Any suggestions?

    I have 3 older ext. hard drives that I've utilized many times. Today while searching for old files, one of the three is no longer recognized by my PowerMac. The drive is not listed in Disk Utility.  Any suggestions?

    Is the computer in you equipment line:
    Dual Core Intel Xenon
    (which is not a PowerMac but a Mac Pro) the one you are asking about, or do you have an older PowerMac?
    If a Mac Pro, their forums are here:
    Mac Pro
    and, as Mac Pros have a totally different architecture from the pre-2005 Macs this forum covers, you may not have the same issues that can affect the older models. If someone didn't notice your equipment line, you could get advice that doesn't apply.
    If you really have a pre-2005 PowerMac, read on.
    If the stubborn external is USB and does not have its own power brick (i.e., it gets power only from the computer's UBS ports--"bus powered"), it may not be getting enough power. As electric motors age, they can demand more power than when new, and the power available on any USB port is limited.
    The typical workabouts to making a computer recognize an aging, bus-powered USB drive are:
    Get a powered USB hub (has its own power brick
    Get a "Y" USB cable: 1 Meter USB 2.0 A to 5 Pin Mini B Cable - Auxiliary USB "Y" Power Design for external hard drives.
    The second gets power from two USB ports on the computer and often that's enough.
    Remember that the USB ports on your keyboard seldom provide enough power even for a thumb drive, so be sure to use the USB ports on the back of the computer.

  • While trying to install Creative cloud for my PC all i keep getting is Searching for Server

    Searching for Server    that is all i get when trying to install creative cloud on my pC   and YES i am running Windows 7 and have high speed internet service.  HELP  

    Sweetpea5154 you may be facing a connection error.  Is the computer you are utilizing on a managed network?  If not then please see Sign in, activation, or connection errors | CC, CS6, CS5.5 - http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html for information on how to resolve connection errors.

  • Windows 8 hangs or freezes whenever search for anything

    Rebuild the Index
    Whenever you try to search for something in windows, its indexing which find the things quickly and brings that to you.If indexing is disabled or corrupt computer won't be able to search and will not present the search results.Windows uses the index to perform very fast searches on your computer.
    The index requires almost no maintenance. However, if the index can't find a file that you know exists in an indexed location, you might need to rebuild the index. Rebuilding the index can take several hours, and searches might be incomplete until the index is fully rebuilt.
    Go to Control panel and open Indexing Options.
    Click the Advanced button at the bottom of the Indexing Options window. This displays a new window titled Advanced Options.
    Click the Index Settings tab if it isn’t selected already.
    Click the Rebuild button to delete and rebuild the file index.
    Click OK to confirm.
    For more information on Advance indexing option you can read article on microsoft's website http://windows.microsoft.com/en-in/windows7/change​-advanced-indexing-options
    Step 2 will always fix this issue but just in case its not helpful try the next Step 3.
    3.Check the Registry Value
    Manual Fix 1 
    1. Press Windows Key + R to get the run dialogue box.
    2. Type "regedit.exe" in the box and hit enter.
    3. Using the box on the left, navigate to the following directory:
    HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
    4. We need to change a registry called "Start_SearchFiles" to a value of 2. If you are like me, yours is already 2. We need to reset this so what we are going to do it change it to 0, then back to 2.
    5. Double-click Start_SearchFiles or right-click and select "Modify" to get the edit box. Change the number under "Value data" to 0 then click "Ok".
    6. Repeat step 5, changing the value back to 2.
    7. Restart your computer.
    Manual Fix 2
    Using the above information navigate to the following directory: Read More on http://bookingtohosting.blogspot.com/2015/04/windo​ws-8-hangs-or-freezes-whenever.html

    Hi,
    Regarding current information we can't say that it related to this exe file.
    We need to use Clean boot mode and Safe mode to test the results:
    Please first restart the Windows in Clean boot and see if the issue still persists after reboot:
    How to perform a clean boot
    http://support.microsoft.com/kb/929135
    If the issue doesn’t appear, you can determine which one can be the cause by using dichotomy in MSconfig. Checking on half of Non-Microsoft service and restart, determining which half of the services cause the issue and repeating to check half of the problematic
    half services.
    If the issue still persists in Clean boot mode, please test in Safe mode.
    Let me know the results in Safe mode.
    If we cannot identify this issue in Clean boot and safe mode, please help to collect the boot trace and let's see what cause this issue:
    Windows Performance Toolkit: Simple Boot Logging
    http://www.autoitconsulting.com/site/performance/windows-performance-toolkit-simple-boot-logging/
    You can upload the etl file from this tool for our research.
    Kate Li
    TechNet Community Support

  • Iphone 5s - Calls Breaking Up - Searching for Network

    Hello.
    I recently started using my new Iphone 5s and I have a big problem.
    Every call I get or make, the call suddenly breaks up during the first minute. My network reception bar drops to 1 bar, then says "searching..." briefly, and then it comes back. But the call is already gone. There are no problems when I remake the call. But I get this problem with every single call that I make. I've never had a problem with my Iphone 4 for 2 years, so I don't think it's about my carrier. Anyone else experiencing the same problem? Any suggestions?

    I have the same problem. My phone keeps "Searching..." for network, and if I don't fix it, it can go on like that for days. I tried several solutions, Reset Network Settings, Reset All Settings, hard reset, and finally I restored my iphone to factory settings then re installed ios 8.1.3, which I had trouble doing because my phone took 4 days to finally have a successful restore. I am not sure if this is about updating to ios 8.1.3, but all of this happened to my iphone 5s a few days after updating. Anyway, after my phone had miraculously went thru with the restore, my phone was back to the way it was, but after 2 days, it went back to searching for network again whenever I get to an area with poor signal. I put phone in Airplane mode for about 10-20 mins, then turn off Airplane mode to check if signal is back. If it still  doesnt, I reset network settings, then airplane mode again. I have not yet used reset all settings since my iPhone restore. I tried to google and see if this really is an ios problem or just my case, then I came across your question. The latest fix I did just this morning is I plugged my phone to my wall charger and tried to dial a number and pressing the green call button several times until the signal went back. That was by far the simplest solution I have discovered, but I still can't say if that IS the solution because it was just my first time to do it. I advise you not to restore your phone because in my case, mine took 4 days to until i was able to use my phone again since restoring wasn't working. You don't want to end up with a dead brick phone. With mine,  I just kept trying until it went thru and I don't think I will be doing the restore all over again because of what happened.  I hope this is just a problem with ios update and that apple will soon find a permanent fix to this.

  • My podcast has been accepted by apple and has been working on the itunes store for a few years until recently. If I search for it I can see some of the episodes but no matter which store I am in I am told I can't few the episodes in my current store

    I have a podcast that has been submitted to itunes a few years back that has been working just fine. The person updating it broke it a few months back, I have fixed the error and reformatted it but the podcast still doesn't work. If I go in itunes and choose to open stream and connect to the podcast URL there, then it works just fine, but If I search for it in the itunes store (search: Jubilee Community Church) then a couple of the episodes show up (see The Art of Marriage by Stephen van Rhyn) but if I click on any of them it just tells me that my podcast is not available in the current store. But I submitted it from the UK store and it is not even available on that store. I have send numerous emails to Apple Support but they have been incredibly unhelpful. I hoped it would update overtime and start working again but its been a month and still nothing, I can't get hold of anyone technical from itunes support to reload my podcast or tell me whats wrong, I can't even resubmit my podcast because it's already been submitted and therefore won't allow me too. I've run out of options, any help would be appreciated!

    A 4th gen iPod can not be upgraded to iOS 8. 7.0.2 is the high version it can run.

  • Why isn't my iTunes store loading properly? It lists everything in text without images, and I can't seem to access the store when I try to search for music or movies etc.

    Why isn't my iTunes store loading properly? It lists everything in text without images, and I can't seem to access the store when I try to search for music or movies etc.

    1) The best way to relocate the iTunes library folder is to move the entire iTunes folder with all subfolders to the new path, then press and hold down shift as start iTunes and keep holding until prompted to choose a library, then browse to the relocated folder and open the file iTunes Library.itl inside it.
    If you've done something different then provide some more details about what is where and I should be able to help.
    2) Purchases on the device should automatically transfer to a Purchased on <DeviceName> playlist, but it my depend a bit on whether automatic iCloud downloads are enabled. If there is a cloudy link then the transfer might not happen. You can use File > Devices > Transfer Purchases. In iTunes you should also check out iTunes Store > Quick Links > Purchased > Music > Not on this computer.
    3) Backup the device, then immediately restore it. In some cases you need to add a restore as new device into that equation. Obbviously not to be attempted until you're sure all your media is in your library. See Recover your iTunes library from your iPod or iOS device should it be needed.
    4) I believe there is complimentary 1 incident 90-day support with hardware purchases, but no free software support for iTunes itself. AppleCare gets you a different level of support.
    tt2

  • In Pages document, how do I search for word and view its frequency and page numbers in a sidebar?

    I have a long document and I want to be able to search for certain key words and phrases, and then see how many times they appear in the document and exactly where.  How do I conduct this sort of search and viewing?  In the past, in Pages and Word, I've been able to view my "finds" in a sidebar but I can't figure out how to activate that service anymore.
    Thanks!

    Here is a word frequency concordance Automator Service that works in both versions of Pages. It does not present a page number reference. It is by descending count, and alphabetically, within the repetitive counts as shown in the image here. In any document, you select the text to process, then Menu > Application Name > Services > Frequency. The Service will open TextEdit with the n-pages of scrollable results. It is 16 pt Helvetica Neue for legibility.
    Here is the code:
    on run {input, parameters}
         try
              set mySelection to input as text
              set formatted_result to concordance(mySelection)
              if formatted_result is not null then
                   set textHeading to "Word Frequency List"
                   tell application "TextEdit"
                   activate
                         set NewDoc to make new document with properties {name:"Concordance"}
                         make new paragraph at beginning of text of NewDoc with data textHeading & return
                         make new paragraph at end of text of NewDoc with data formatted_result
                         tell text of NewDoc
                               set font to "Helvetica Neue"
                               set size to 16
                               set color of paragraph 1 to {0, 0, 65535}
                         end tell
                        end tell
              else
                        display dialog with title ¬
                         "No input selected" with icon stop ¬
                          giving up after 15
              end if
         on error errmsg number errnum
                    display alert ¬
                               "AppleScript Error" message errmsg & "[" & errnum & "]" as critical ¬
                                  giving up after 30
         end try
         return input
    end run
    on concordance(mySelection)
    -- Use Ruby to count word frequency and alphabetically sort words
        set rb to ¬
        "selected = String.new\nfreqs = Hash.new(0)\nselected = ARGV.join('  ').gsub(/[,.]/, \"\")\n
         words = selected.split(/[^\\w-]+/)\nwords.each { |word| freqs[word] += 1 }\n
         freqs_sorted = freqs.sort do |a,b|\n\t
         a.last == b.last ? a.first <=> b.first : b.last <=> a.last\nend\n
         freqs_sorted.each { |k,v| printf \"[ %8s ]          %s\", v, k }"
        do shell script "/usr/bin/ruby -e " & rb's quoted form & space & mySelection's quoted form
    end concordance
    Launch /Applications/Automator and choose New Document, then click the Service icon, and then select the Choose button.
    On the left, you will have a list of Libraries from which to choose workflow items. Find Library > Utilities. In the adjacent column, locate the Run Applescript workflow. Click on it, then drag and drop it in the large workflow window to your right.
    At the top, you can select Service receives text in any application. Leave Output replaces selected text unchecked.
    In your Run AppleScript workflow window, you will see AppleScript boilerplate. Click on it and press command+A, then backspace to delete this content. Copy and paste the above code into this Run AppleScript workflow window. Press the Run button in Automator's upper right corner. If (and it should) a TextEdit window pops up, you are good, and you want to press File > Save. A dialog box will pop-up where you can name your Service. I called my Frequency, you may wish to call it something else. Once you have save it, you can exit Automator. Services are deposited in yourlogin directory/Library/Services.
    If you have a Pages document open with text, either select it, or command+a to select the entire document. Now, you select your Service via Pages > Services > Frequency. This will now pop-up a new TextEdit document with the results. If you want to save this new document, you must use option+File to Save as...

  • Jabber - Search for phone Numbers (extensions)

    Hi there,
    as on the old Cisco Personal Communicator there was a possibillity to search for extension numbers on the search field. If I enter an extension number on the Jabber Client on Windows, there is no Name and Picture shown from this employee. For example, if you type in 1234 in the field it just says "call 1234" but I want so find the employee which extension is 1234.
    On the jabber-config.xml I already tryed the UDS and EDI method.
    So I'm just asking if there is a general problem with this function or if this is just an configuration issue. If it would help, I'll post the jabber-config.xml.
    Thanks for a reply.
    regards
    Marc

    Hi Marc,
    Currently this is not supported. It is tententively planned for 9.4 which has no current release date.
    Thanks,
    - Colin

  • My app store wont let me search for apps it wont load anything

    when i go to search for an app in the app store it wont load anything i even tried searching for angry birds becasue i know theres an app for that and nothing loads at all i have turned off and on my phone and still nothing!

    Tap Settings App > General > Reset > Reset Network Settings. Then in Settings make sure Cellular Data is ON. If you are in a WiFi area, relog into WiFi.

  • Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this?  FYI...under settings i

    Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this?  FYI...under settings i

    If you are missing using google maps - try the Nokia map app called "here"

  • Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    Hi. I am using the iPhone 4S and when I'm searching for places using Google it does not automatically detect my location. How do I change this? FYI...under settings i have it set at "Use new precise locations from my device."

    If you are missing using google maps - try the Nokia map app called "here"

Maybe you are looking for

  • BI 7.0 front end installation problem

    Hi Gurus When I click on the Business Explorer -> Analyzer 7.10 It opens up MS Excel but when I click on the connect tool icon the sapgui connect does not showup We are on SAPGUI 7.10 patch 03. Also from the query desiger ,when i go to View>>>standar

  • I am not able to run JSP program

    hi I have done some jsp programs. i have installed tomcat 5. but when i tries to execute jsp program it gives error as " Unable to get jstl ". it is not getting jasper-comppile.jar file. Please any one can tell me how to specify path for jasper-compi

  • How can i change my JAVA card life cycle state to OP_READY?

    I found the below script in this link and run it via `GPShell` on my java card and now I can't run `gpj -list` in `GPJ`! My questions: 1- What is this code for? changing Card Domain Manager status from OP_READY to Secured? 2- Why I can't find anywher

  • Attach Secure PDF to email?

    Does anyone know a way to attach a secure (i.e. password-protected) PDF to an email. I've tried using Mail and through gmail, but the thing won't attach. I've secured it through Acrobat (using 9.4.3). I've tried using the attach to email menu option

  • Leopard and entourage 10.1.6

    I updated to 10.5.3 last week. I did the back up with time Machine. I Repaired Permissions. I use Microsoft Entourage 10.1.6 as my mail program. Ever since I performed the update I cannot open any emails that are not from private parties. EX: I subsc